-
Notifications
You must be signed in to change notification settings - Fork 14
feat: skill security audit (skill-audit crate + add-skill gate) #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Fldicoahkiin
wants to merge
9
commits into
main
Choose a base branch
from
feat/skill-audit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fea1f8f
feat(skill-audit): add offline security-audit crate for skills
Fldicoahkiin aebbae9
feat(cli): gate `add skill` on the security audit
Fldicoahkiin 462575e
feat(skill-audit): add ast-grep AST layer for code files
Fldicoahkiin eabdd30
revert: drop the ast-grep code-scanning layer
Fldicoahkiin 8cd71dd
feat(skill-audit): run install-time audit in the skills.sh API
Fldicoahkiin 4e5c32e
Merge remote-tracking branch 'origin/main' into feat/skill-audit
Fldicoahkiin 73b0c29
feat(skill-audit): finding line numbers + audit on github scan
Fldicoahkiin e8a282a
style(skill-audit): rustfmt finding_from_rule signature
Fldicoahkiin df68e9a
fix(skill-audit): make InstallSkillRequest force_unsafe/session_id op…
Fldicoahkiin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| //! DTOs mirroring `skill_audit::AuditReport` at the HTTP boundary, with ts-rs | ||
| //! bindings for the frontend. Kept separate so the skill-audit crate stays free | ||
| //! of ts-rs, matching how the other DTOs mirror core models. | ||
|
|
||
| use serde::{Deserialize, Serialize}; | ||
| use ts_rs::TS; | ||
|
|
||
| use skill_audit::{ | ||
| AuditReport, Category, Confidence, Finding, FindingSource, Severity, | ||
| Verdict, | ||
| }; | ||
|
|
||
| #[derive(Debug, Serialize, TS)] | ||
| #[ts(export)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum VerdictDto { | ||
| Benign, | ||
| Suspicious, | ||
| Malicious, | ||
| } | ||
|
|
||
| #[derive(Debug, Serialize, TS)] | ||
| #[ts(export)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum ConfidenceDto { | ||
| Low, | ||
| Medium, | ||
| High, | ||
| } | ||
|
|
||
| #[derive(Debug, Serialize, TS)] | ||
| #[ts(export)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum SeverityDto { | ||
| Info, | ||
| Low, | ||
| Medium, | ||
| High, | ||
| Critical, | ||
| } | ||
|
|
||
| #[derive(Debug, Serialize, TS)] | ||
| #[ts(export)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum CategoryDto { | ||
| CredentialExfil, | ||
| DataExfil, | ||
| CommandInjection, | ||
| PromptInjection, | ||
| ToolChaining, | ||
| Persistence, | ||
| HostTamper, | ||
| Obfuscation, | ||
| Other, | ||
| } | ||
|
|
||
| #[derive(Debug, Serialize, TS)] | ||
| #[ts(export)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub enum FindingSourceDto { | ||
| Yara, | ||
| Injection, | ||
| } | ||
|
|
||
| #[derive(Debug, Serialize, TS)] | ||
| #[ts(export)] | ||
| pub struct FindingDto { | ||
| pub rule_id: String, | ||
| pub category: CategoryDto, | ||
| pub severity: SeverityDto, | ||
| pub file: String, | ||
| pub line: Option<u32>, | ||
| pub evidence: String, | ||
| pub source: FindingSourceDto, | ||
| } | ||
|
|
||
| #[derive(Debug, Serialize, TS)] | ||
| #[ts(export)] | ||
| pub struct AuditReportDto { | ||
| pub verdict: VerdictDto, | ||
| pub confidence: ConfidenceDto, | ||
| pub findings: Vec<FindingDto>, | ||
| pub summary: String, | ||
| } | ||
|
|
||
| /// Request to audit a skill at a local path (directory, `.skill`/`.zip`, `.md`). | ||
| #[derive(Debug, Deserialize, TS)] | ||
| #[ts(export)] | ||
| pub struct AuditRequest { | ||
| pub path: String, | ||
| } | ||
|
|
||
| impl From<Verdict> for VerdictDto { | ||
| fn from(v: Verdict) -> Self { | ||
| match v { | ||
| Verdict::Benign => Self::Benign, | ||
| Verdict::Suspicious => Self::Suspicious, | ||
| Verdict::Malicious => Self::Malicious, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<Confidence> for ConfidenceDto { | ||
| fn from(c: Confidence) -> Self { | ||
| match c { | ||
| Confidence::Low => Self::Low, | ||
| Confidence::Medium => Self::Medium, | ||
| Confidence::High => Self::High, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<Severity> for SeverityDto { | ||
| fn from(s: Severity) -> Self { | ||
| match s { | ||
| Severity::Info => Self::Info, | ||
| Severity::Low => Self::Low, | ||
| Severity::Medium => Self::Medium, | ||
| Severity::High => Self::High, | ||
| Severity::Critical => Self::Critical, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<Category> for CategoryDto { | ||
| fn from(c: Category) -> Self { | ||
| match c { | ||
| Category::CredentialExfil => Self::CredentialExfil, | ||
| Category::DataExfil => Self::DataExfil, | ||
| Category::CommandInjection => Self::CommandInjection, | ||
| Category::PromptInjection => Self::PromptInjection, | ||
| Category::ToolChaining => Self::ToolChaining, | ||
| Category::Persistence => Self::Persistence, | ||
| Category::HostTamper => Self::HostTamper, | ||
| Category::Obfuscation => Self::Obfuscation, | ||
| Category::Other => Self::Other, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<FindingSource> for FindingSourceDto { | ||
| fn from(s: FindingSource) -> Self { | ||
| match s { | ||
| FindingSource::Yara => Self::Yara, | ||
| FindingSource::Injection => Self::Injection, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<Finding> for FindingDto { | ||
| fn from(f: Finding) -> Self { | ||
| Self { | ||
| rule_id: f.rule_id, | ||
| category: f.category.into(), | ||
| severity: f.severity.into(), | ||
| file: f.file, | ||
| line: f.line, | ||
| evidence: f.evidence, | ||
| source: f.source.into(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<AuditReport> for AuditReportDto { | ||
| fn from(r: AuditReport) -> Self { | ||
| Self { | ||
| verdict: r.verdict.into(), | ||
| confidence: r.confidence.into(), | ||
| findings: r.findings.into_iter().map(Into::into).collect(), | ||
| summary: r.summary, | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| pub mod agents; | ||
| pub mod audit; | ||
| pub mod common; | ||
| pub mod credential; | ||
| pub mod inference; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: AkaraChen/aghub
Length of output: 1076
Pin
yara-xwith an immutablerevinCargo.tomlCargo.tomlusestag = "v1.17.0", butCargo.lockalready resolves that tag to commite0096cd41fe16be76ca5321618ac880d1894b086. Still, addrevin the manifest to make the pin explicit (defense-in-depth, and safer whenCargo.lockchanges or is not present).🔒 Suggested manifest hardening
🤖 Prompt for AI Agents