Skip to content

Add repo-wide audit engine, verified remediation, and release hardening - #43

Open
mesrikanthreddy wants to merge 1 commit into
devfrom
feature/repo-wide-audit-engine
Open

Add repo-wide audit engine, verified remediation, and release hardening#43
mesrikanthreddy wants to merge 1 commit into
devfrom
feature/repo-wide-audit-engine

Conversation

@mesrikanthreddy

Copy link
Copy Markdown
Collaborator

Summary

  • Repo-wide audit (kshield agent <name>, POST /api/v1/audit): scans every git-tracked file in one pass with a real import/symbol/route graph, graph-aware Broken Access Control detection, typosquat + undeclared-dependency checks, and a batched dependency-registry lookup pass that fixes a real timeout on large repos.
  • Verified auto-remediation (ksword.py), replacing the old remediation engine — every patch is applied in-memory and re-checked against the same rule that raised the finding before it's ever returned, instead of potentially referencing symbols that don't exist.
  • VS Code extension is live on the Marketplace; docs updated to lead with it.
  • Windows added as a release target (x86_64-pc-windows-msvc) — compile-verified via local cross-compilation (real PE32+ binary produced), but not yet run-tested on an actual Windows machine — treat as best-effort until confirmed.
  • npm package renamed kshield@ytt-global/kshield — the unscoped name was squatted by an unrelated third-party CLI, so npx kshield init silently ran someone else's tool. Installed command is still kshield.
  • New MCP server (mcp-server/) exposes the scan/audit engine as tools for MCP-aware agents (Claude Code, Claude Desktop).
  • docs/algorithms.md documents the actual math behind detection (Shannon entropy thresholds, Levenshtein typosquat matching, signature-based false-positive memory).
  • backend/tests/ is intentionally gitignored, not shipped in this repo — the engine work above is backed by a 186-test local suite (all passing), but the tests aren't committed. CONTRIBUTING.md reflects this.

Test plan

  • Backend: 186/186 tests passed locally before this suite was excluded from the repo
  • Functional test of POST /api/v1/audit against real files — correct graph stats and findings
  • Rust CLI (cargo build) — clean, zero warnings
  • Frontend (tsc --noEmit, npm run build) — clean
  • kshield agent run end-to-end via the compiled CLI against this repo — matches API-level results
  • Windows target cross-compiled locally and confirmed as a real PE32+ executable — not run-tested on Windows
  • Real Windows verification (needs someone with an actual Windows machine)
  • vsce publish / npm publish for this batch (manual, credential-gated, not part of this PR)

Repo-wide audit (kshield agent, POST /api/v1/audit) scans every git-tracked
file in one pass instead of just the staged diff: a real import/symbol/route
graph, graph-aware Broken Access Control detection, typosquat and undeclared-
dependency checks, and a batched dependency-registry lookup pass that fixed a
real timeout on large repos. Remediation patches now come from ksword, which
proposes a fix, applies it in-memory, and re-runs the original check before
ever returning the diff — replacing the old engine, which could hand back a
patch referencing symbols that didn't exist.

Also: the VS Code extension is live on the Marketplace; Windows is now a
release target (compile-verified via cross-compilation, not yet run-tested
on real Windows); the npm package is renamed to the scoped @ytt-global/kshield
since the unscoped name was squatted by an unrelated package; and a new MCP
server exposes the scan/audit engine as tools for MCP-aware agents.

backend/tests/ is intentionally gitignored and not committed — the engine
work above is backed by a 186-test local suite (all passing), but the tests
themselves aren't shipped in the public repo. CONTRIBUTING.md's testing
section reflects this.
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.



def _extract_generic(filename: str, content: str, graph: RepoGraph) -> None:
roots = {_js_package_root(raw) for raw in _JS_IMPORT_RE.findall(content)}
def _replace(m: re.Match) -> str:
return " " if m.group("comment") is not None else m.group("string")

return _JS_COMMENT_OR_STRING_RE.sub(_replace, code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants