Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

rules: scope package sources to the install segment, keychain flags case-sensitive

Claudeb61fb4ce1074
diff --git a/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/builtin-security-review.spec.ts b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/builtin-security-review.spec.ts
index f66d8e72..1123f57d 100644
--- a/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/builtin-security-review.spec.ts
+++ b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/builtin-security-review.spec.ts
@@ -5,7 +5,7 @@ test('security review: findings grouped by risk, the combination flagged, eviden
const frame = page.frameLocator('iframe.lens-frame');
await expect(frame.locator('#root')).toBeVisible();
- await expect(frame.locator('#root > p').first()).toHaveText('5 findings across 77 rules evaluated.');
+ await expect(frame.locator('#root > p').first()).toHaveText('5 findings across 81 rules evaluated.');
await expect(frame.locator('.alert')).toContainText('combines untrusted input, sensitive access and a consequential action');
const rows = frame.locator('tbody tr');
diff --git a/rules/credential-access/os-keychain-secret-read.rule.yaml b/rules/credential-access/os-keychain-secret-read.rule.yaml
index 8f4466d8..a90e8706 100644
--- a/rules/credential-access/os-keychain-secret-read.rule.yaml
+++ b/rules/credential-access/os-keychain-secret-read.rule.yaml
@@ -22,7 +22,7 @@ taxonomy:
match: >
e.event.action == "command.executed" && (
e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(secret-tool\\s+(lookup|search)\\b|kwallet-query\\s+([^;&|\\n]*\\s)?(-r|--read-password)\\b|vaultcmd(\\.exe)?\\s+/listcreds\\b)") ||
- e.command.command.matches("(?i)\\b(find-(generic|internet)-password\\b([^;&|\\n]*\\s)?-[a-z]*[wg][a-z]*\\b|dump-keychain\\b([^;&|\\n]*\\s)?-[a-z]*d[a-z]*\\b|get-storedcredential|get-secret\\s+([^;&|\\n]*\\s)?-asplaintext|\\[windows\\.security\\.credentials\\.passwordvault\\])")
+ e.command.command.matches("(?i)\\b(find-(generic|internet)-password\\b([^;&|\\n]*\\s)?(?-i:-[a-zA-Z]*[wg][a-zA-Z]*)\\b|dump-keychain\\b([^;&|\\n]*\\s)?(?-i:-[a-zA-Z]*d[a-zA-Z]*)\\b|get-storedcredential|get-secret\\s+([^;&|\\n]*\\s)?-asplaintext|\\[windows\\.security\\.credentials\\.passwordvault\\])")
)
emit:
@@ -77,6 +77,18 @@ tests:
- event: { action: command.executed }
command: { command: "Get-Secret -Name GitHubToken -AsPlainText" }
session: { id: s1 }
+ - name: macos_attribute_filter_upper_g
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "security find-generic-password -s build -G ci-label" }
+ session: { id: s1 }
+ - name: macos_attribute_filter_clustered
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "security find-generic-password -s build -aG me" }
+ session: { id: s1 }
- name: macos_find_identity
verdict: no_match
events:
diff --git a/rules/risky-command/package-install-from-untrusted-source.rule.yaml b/rules/risky-command/package-install-from-untrusted-source.rule.yaml
index ba12e50b..a17c2df5 100644
--- a/rules/risky-command/package-install-from-untrusted-source.rule.yaml
+++ b/rules/risky-command/package-install-from-untrusted-source.rule.yaml
@@ -22,16 +22,12 @@ taxonomy:
match: >
e.event.action == "command.executed" && (
(
- e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(([^\\s;&|]*/)?(pip[0-9.]*|pipx|uv\\s+pip|uv\\s+tool|python[0-9.]*\\s+-m\\s+pip)\\s+install|uv\\s+add|poetry\\s+add)\\b") && (
- e.command.command.matches("(?i)\\s['\\\"]?(git\\+|[\\w.\\[\\],-]+\\s*@\\s*(git\\+)?(https?|ssh|git|file)://|(https?|ssh|git)://[^\\s'\\\"]*\\.(whl|tar\\.gz|tgz|tar\\.bz2|zip|git)(#[^\\s'\\\"]*)?['\\\"]?(\\s|$))") ||
- e.command.command.matches("(?i)\\s(--extra-index-url|--trusted-host)(\\s|=)") ||
- (e.command.command.matches("(?i)\\s(-i|--index-url|--index)(\\s+|=)['\\\"]?https?://") && !e.command.command.matches("(?i)\\s(-i|--index-url|--index)(\\s+|=)['\\\"]?https://pypi\\.org/simple/?['\\\"]?(\\s|$)"))
- )
+ e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(([^\\s;&|]*/)?(pip[0-9.]*|pipx|uv\\s+pip|uv\\s+tool|python[0-9.]*\\s+-m\\s+pip)\\s+install|uv\\s+add|poetry\\s+add)\\b[^;&|\\n]*?\\s['\\\"]?(git\\+|[\\w.\\[\\],-]+\\s*@\\s*(git\\+)?(https?|ssh|git|file)://|(https?|ssh|git)://[^\\s'\\\"]*\\.(whl|tar\\.gz|tgz|tar\\.bz2|zip|git)(#[^\\s'\\\"]*)?['\\\"]?(\\s|$))") ||
+ e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(([^\\s;&|]*/)?(pip[0-9.]*|pipx|uv\\s+pip|uv\\s+tool|python[0-9.]*\\s+-m\\s+pip)\\s+install|uv\\s+add|poetry\\s+add)\\b[^;&|\\n]*?\\s(--extra-index-url|--trusted-host)(\\s|=)") ||
+ (e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(([^\\s;&|]*/)?(pip[0-9.]*|pipx|uv\\s+pip|uv\\s+tool|python[0-9.]*\\s+-m\\s+pip)\\s+install|uv\\s+add|poetry\\s+add)\\b[^;&|\\n]*?\\s(-i|--index-url|--index)(\\s+|=)['\\\"]?https?://") && !e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(([^\\s;&|]*/)?(pip[0-9.]*|pipx|uv\\s+pip|uv\\s+tool|python[0-9.]*\\s+-m\\s+pip)\\s+install|uv\\s+add|poetry\\s+add)\\b[^;&|\\n]*?\\s(-i|--index-url|--index)(\\s+|=)['\\\"]?https://pypi\\.org/simple/?['\\\"]?(\\s|$)"))
) || (
- e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(npm\\s+(install|i|add|ci)|pnpm\\s+(add|install|i)|yarn\\s+(global\\s+)?add|bun\\s+(add|install|i))\\b") && (
- e.command.command.matches("(?i)\\s['\\\"]?(@?[\\w./-]+@)?(git\\+|github:|gitlab:|bitbucket:|gist:|git://|ssh://|https?://[^\\s'\\\"]*\\.(tgz|tar\\.gz|git)(#[^\\s'\\\"]*)?['\\\"]?(\\s|$))") ||
- (e.command.command.matches("(?i)\\s--registry(\\s+|=)['\\\"]?https?://") && !e.command.command.matches("(?i)\\s--registry(\\s+|=)['\\\"]?https://registry\\.(npmjs\\.org|yarnpkg\\.com)/?['\\\"]?(\\s|$)"))
- )
+ e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(npm\\s+(install|i|add|ci)|pnpm\\s+(add|install|i)|yarn\\s+(global\\s+)?add|bun\\s+(add|install|i))\\b[^;&|\\n]*?\\s['\\\"]?(@?[\\w./-]+@)?(git\\+|github:|gitlab:|bitbucket:|gist:|git://|ssh://|https?://[^\\s'\\\"]*\\.(tgz|tar\\.gz|git)(#[^\\s'\\\"]*)?['\\\"]?(\\s|$))") ||
+ (e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(npm\\s+(install|i|add|ci)|pnpm\\s+(add|install|i)|yarn\\s+(global\\s+)?add|bun\\s+(add|install|i))\\b[^;&|\\n]*?\\s--registry(\\s+|=)['\\\"]?https?://") && !e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(npm\\s+(install|i|add|ci)|pnpm\\s+(add|install|i)|yarn\\s+(global\\s+)?add|bun\\s+(add|install|i))\\b[^;&|\\n]*?\\s--registry(\\s+|=)['\\\"]?https://registry\\.(npmjs\\.org|yarnpkg\\.com)/?['\\\"]?(\\s|$)"))
) ||
e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(cargo\\s+install\\s+([^;&|\\n]*\\s)?--git\\b|gem\\s+install\\s+([^;&|\\n]*\\s)?(--source|--clear-sources)\\b)")
)
@@ -172,6 +168,36 @@ tests:
- event: { action: command.executed }
command: { command: "cargo install ripgrep" }
session: { id: s1 }
+ - name: pip_then_git_clone
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pip install -r requirements.txt && git clone https://github.com/org/repo.git" }
+ session: { id: s1 }
+ - name: npm_ci_then_git_clone
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "npm ci && git clone https://github.com/org/repo.git" }
+ session: { id: s1 }
+ - name: pip_editable_then_download
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pip install -e . && curl -O https://example.com/data.zip" }
+ session: { id: s1 }
+ - name: pip_default_then_custom_index_elsewhere
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "pip install requests; echo --index-url https://pkgs.example.test/simple" }
+ session: { id: s1 }
+ - name: cd_then_pip_git_url
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "cd /tmp && pip install git+https://github.com/someone/helper.git" }
+ session: { id: s1 }
- name: git_clone_not_install
verdict: no_match
events: