feat(context): add @atr provider for AI agent threat scanning#12194
feat(context): add @atr provider for AI agent threat scanning#12194eeee2345 wants to merge 1 commit intocontinuedev:mainfrom
Conversation
Introduces ATRSecurityContextProvider that loads the Agent Threat Rules ruleset (optional 'agent-threat-rules' npm dependency) and surfaces HIGH/CRITICAL matches for the current file as chat context items. Mirrors ProblemsContextProvider structure; lazy-imports the dependency so users who don't install it see a friendly install hint instead. Zero network calls, zero telemetry.
|
I have read the CLA Document and I hereby sign the CLA Panguard AI seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
There was a problem hiding this comment.
2 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="core/context/providers/ATRSecurityContextProvider.ts">
<violation number="1" location="core/context/providers/ATRSecurityContextProvider.ts:49">
P2: Failed engine initialization is cached permanently, so the provider cannot recover or retry after a transient load failure.</violation>
<violation number="2" location="core/context/providers/ATRSecurityContextProvider.ts:104">
P2: Empty open files are incorrectly treated as missing files due to a falsy check on `file.contents`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
|
|
||
| async function getEngine(): Promise<any> { | ||
| if (!enginePromise) { | ||
| enginePromise = (async () => { |
There was a problem hiding this comment.
P2: Failed engine initialization is cached permanently, so the provider cannot recover or retry after a transient load failure.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At core/context/providers/ATRSecurityContextProvider.ts, line 49:
<comment>Failed engine initialization is cached permanently, so the provider cannot recover or retry after a transient load failure.</comment>
<file context>
@@ -0,0 +1,156 @@
+
+async function getEngine(): Promise<any> {
+ if (!enginePromise) {
+ enginePromise = (async () => {
+ try {
+ const mod = await import("agent-threat-rules");
</file context>
| } | ||
|
|
||
| const file = await extras.ide.getCurrentFile(); | ||
| if (!file || !file.contents) { |
There was a problem hiding this comment.
P2: Empty open files are incorrectly treated as missing files due to a falsy check on file.contents.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At core/context/providers/ATRSecurityContextProvider.ts, line 104:
<comment>Empty open files are incorrectly treated as missing files due to a falsy check on `file.contents`.</comment>
<file context>
@@ -0,0 +1,156 @@
+ }
+
+ const file = await extras.ide.getCurrentFile();
+ if (!file || !file.contents) {
+ return [
+ {
</file context>
| if (!file || !file.contents) { | |
| if (!file || file.contents === undefined) { |
Summary
Adds an
@atrcontext provider that scans the currently open file against the Agent Threat Rules (ATR) ruleset — 314 MIT-licensed YAML rules for AI agent threats (prompt injection, MCP tool poisoning, context exfiltration, skill-package compromise).Invoking
@atrin chat attaches each HIGH/CRITICAL rule match as a context item so the model sees the finding alongside the code.Why this fits Continue
ProblemsContextProvider— reads current-file state, returns oneContextItemper finding.agent-threat-rulesis lazily imported. Users who don't install it see a one-line install hint; no bundle-size impact for users who don't use@atr.@problems(TS/lint diagnostics);@atrtargets AI-specific attack patterns that static analyzers don't cover.Context on ATR
ATR is an open detection standard for AI agent threats. The ruleset is already integrated into two upstream ecosystems:
Benchmarks: 97.1% recall on NVIDIA garak's 666 in-the-wild jailbreak corpus; 100% recall on a 498-sample labeled SKILL.md benchmark; 0 false positives on a 432-sample benign skill corpus.
Source: https://github.com/Agent-Threat-Rule/agent-threat-rules
Paper: https://doi.org/10.5281/zenodo.19178002
Files
core/context/providers/ATRSecurityContextProvider.tscore/context/providers/ATRSecurityContextProvider.test.tscore/context/providers/index.tsTests
Covers: HIGH/CRITICAL match surfacing, benign file reports "clean", missing dependency returns friendly install hint, missing open file handled gracefully.
Alternatives considered
If maintainers prefer external packaging over an in-tree provider, I can ship this as
@continuedev/context-atr(or in the ATR org) using Continue'sCustomContextProviderpath. Opening here first to gauge preference — happy to pivot to an external package + a small docs PR linking to it.Also happy to split into two PRs (provider + tests) or narrow scope if that fits the review cadence better.
Summary by cubic
Adds a new
@atrcontext provider that scans the current file with the Agent Threat Rules and surfaces HIGH/CRITICAL findings as chat context items. This helps catch prompt injection, tool poisoning, and related threats with no network calls.New Features
ATRSecurityContextProviderand register as@atr.Dependencies
agent-threat-rulesto enable scanning —npm install agent-threat-rules.Written for commit 91bcbb7. Summary will update on new commits.