Skip to content

Commit 7dfe161

Browse files
fix: reject unknown matcher slugs
Fail scan when --matchers includes unknown slugs. Fix README grammar (deepsec is an...). Signed-off-by: Divyam Agrawal <ludicrouslytrue@gmail.com>
1 parent dab45cf commit 7dfe161

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# deepsec
22

3-
`deepsec` an agent-powered vulnerability scanner that you can run in your own infrastructure, optimized to perform on-demand review of all code in existing
3+
`deepsec` is an agent-powered vulnerability scanner that you can run in your own infrastructure, optimized to perform on-demand review of all code in existing
44
large-scale repos.
55

66
`deepsec` is designed to surface hard-to-find issues that have been lurking in applications for a long time. It is configured to use the best models at maximum thinking levels, meaning scans can cost thousands or even tens-of-thousands of dollars for large codebases. Our customers have found the cost worth it for how quickly they were able to patch vulnerabilities that would have otherwise gone unfixed.

e2e/scan.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,14 @@ describe("scan e2e", () => {
8686
const meta = JSON.parse(fs.readFileSync(runPath, "utf-8"));
8787
expect(meta.scannerConfig.matcherSlugs).toEqual(["xss", "rce"]);
8888
});
89+
90+
it("throws when matcher filter includes an unknown slug", async () => {
91+
await expect(
92+
scan({
93+
projectId: PROJECT_ID,
94+
root: FIXTURES,
95+
matcherSlugs: ["xss", "does-not-exist"],
96+
}),
97+
).rejects.toThrow(/Unknown matcher slug\(s\): does-not-exist/);
98+
});
8999
});

packages/scanner/src/matcher-registry.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ export class MatcherRegistry {
1616
}
1717

1818
getBySlugs(slugs: string[]): MatcherPlugin[] {
19-
return slugs
20-
.map((s) => this.matchers.get(s))
21-
.filter((m): m is MatcherPlugin => m !== undefined);
19+
const missing = slugs.filter((slug) => !this.matchers.has(slug));
20+
if (missing.length > 0) {
21+
throw new Error(`Unknown matcher slug(s): ${missing.join(", ")}`);
22+
}
23+
return slugs.map((slug) => this.matchers.get(slug)!);
2224
}
2325

2426
slugs(): string[] {

0 commit comments

Comments
 (0)