torusguard 0.9.5 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.torusguard/.manifest.json +98 -79
- package/.torusguard/config/torusguard.json +1 -1
- package/.torusguard/references/csharp-security.md +41 -0
- package/.torusguard/references/go-security.md +41 -0
- package/.torusguard/references/java-security.md +40 -0
- package/.torusguard/references/polyglot-security-matrix.md +25 -0
- package/.torusguard/references/rust-security.md +40 -0
- package/.torusguard/rules/custom/.gitkeep +1 -0
- package/.torusguard/rules/custom/README.md +30 -0
- package/.torusguard/runs/report-latest.html +328 -0
- package/.torusguard/schemas/golden-recipe.schema.json +75 -0
- package/.torusguard/schemas/memory-context.schema.json +95 -0
- package/.torusguard/schemas/memory-event.schema.json +70 -0
- package/.torusguard/schemas/memory-pattern.schema.json +65 -0
- package/.torusguard/scripts/diff_guard.py +202 -15
- package/.torusguard/scripts/finding_scorer.py +199 -86
- package/.torusguard/scripts/html_reporter.py +628 -0
- package/.torusguard/scripts/manifest_builder.py +7 -5
- package/.torusguard/scripts/memory_engine.py +1334 -0
- package/.torusguard/scripts/monorepo_detector.py +123 -10
- package/.torusguard/scripts/rules_sync.py +321 -0
- package/.torusguard/scripts/run_manager.py +171 -89
- package/.torusguard/scripts/stack_detect.py +458 -26
- package/.torusguard/skills/torusguard/SKILL.md +4 -3
- package/.torusguard/skills/torusguard/bootstrap.py +344 -56
- package/.torusguard/skills/torusguard/references/csharp-security.md +41 -0
- package/.torusguard/skills/torusguard/references/go-security.md +41 -0
- package/.torusguard/skills/torusguard/references/java-security.md +40 -0
- package/.torusguard/skills/torusguard/references/polyglot-security-matrix.md +25 -0
- package/.torusguard/skills/torusguard/references/rust-security.md +40 -0
- package/.torusguard/skills/torusguard-audit/SKILL.md +25 -25
- package/.torusguard/skills/torusguard-harden/SKILL.md +3 -3
- package/.torusguard/skills/torusguard-recheck/SKILL.md +3 -3
- package/.torusguard/workflows/memory.md +53 -0
- package/README.md +307 -401
- package/bin/torusguard.js +204 -6
- package/package.json +1 -1
- package/skills/torusguard/SKILL.md +4 -3
- package/skills/torusguard/bootstrap.py +68 -4
- package/skills/torusguard/payload/.manifest.json +98 -79
- package/skills/torusguard/payload/config/torusguard.json +1 -1
- package/skills/torusguard/payload/references/csharp-security.md +41 -0
- package/skills/torusguard/payload/references/go-security.md +41 -0
- package/skills/torusguard/payload/references/java-security.md +40 -0
- package/skills/torusguard/payload/references/polyglot-security-matrix.md +25 -0
- package/skills/torusguard/payload/references/rust-security.md +40 -0
- package/skills/torusguard/payload/rules/custom/.gitkeep +1 -0
- package/skills/torusguard/payload/rules/custom/README.md +30 -0
- package/skills/torusguard/payload/schemas/golden-recipe.schema.json +75 -0
- package/skills/torusguard/payload/schemas/memory-context.schema.json +95 -0
- package/skills/torusguard/payload/schemas/memory-event.schema.json +70 -0
- package/skills/torusguard/payload/schemas/memory-pattern.schema.json +65 -0
- package/skills/torusguard/payload/scripts/diff_guard.py +202 -15
- package/skills/torusguard/payload/scripts/finding_scorer.py +199 -86
- package/skills/torusguard/payload/scripts/html_reporter.py +628 -0
- package/skills/torusguard/payload/scripts/manifest_builder.py +7 -5
- package/skills/torusguard/payload/scripts/memory_engine.py +1334 -0
- package/skills/torusguard/payload/scripts/monorepo_detector.py +123 -10
- package/skills/torusguard/payload/scripts/rules_sync.py +321 -0
- package/skills/torusguard/payload/scripts/run_manager.py +171 -89
- package/skills/torusguard/payload/scripts/stack_detect.py +458 -26
- package/skills/torusguard/payload/skills/torusguard/SKILL.md +4 -3
- package/skills/torusguard/payload/skills/torusguard/bootstrap.py +344 -56
- package/skills/torusguard/payload/skills/torusguard/references/csharp-security.md +41 -0
- package/skills/torusguard/payload/skills/torusguard/references/go-security.md +41 -0
- package/skills/torusguard/payload/skills/torusguard/references/java-security.md +40 -0
- package/skills/torusguard/payload/skills/torusguard/references/polyglot-security-matrix.md +25 -0
- package/skills/torusguard/payload/skills/torusguard/references/rust-security.md +40 -0
- package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +25 -25
- package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +3 -3
- package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +3 -3
- package/skills/torusguard/payload/workflows/memory.md +53 -0
- package/skills/torusguard-audit/SKILL.md +25 -25
- package/skills/torusguard-harden/SKILL.md +3 -3
- package/skills/torusguard-recheck/SKILL.md +3 -3
- package/.torusguard/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
- package/.torusguard/scripts/__pycache__/monorepo_detector.cpython-311.pyc +0 -0
- package/skills/torusguard/__pycache__/bootstrap.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
- package/skills/torusguard/payload/scripts/__pycache__/monorepo_detector.cpython-311.pyc +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: C# & ASP.NET Core Security
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** A project is identified as a C# / .NET application (`*.csproj`, `*.sln`, ASP.NET Core detected).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛡️ Key Inspection Areas & Rules
|
|
8
|
+
|
|
9
|
+
### 1. Authentication & Authorization
|
|
10
|
+
* `TG-AUTH-001`: Ensure controllers and endpoints have `[Authorize]` attributes.
|
|
11
|
+
* Prohibit unvetted `[AllowAnonymous]` on sensitive business logic or user data endpoints.
|
|
12
|
+
|
|
13
|
+
### 2. Entity Framework Core & SQL Injection
|
|
14
|
+
* `TG-INPUT-002`: Use LINQ expressions or `FromSqlInterpolated` with interpolated string syntax (EF Core converts parameters automatically).
|
|
15
|
+
* Prohibit raw `FromSqlRaw` with un-parameterized string concatenations.
|
|
16
|
+
* `TG-DB-004`: Configure Global Query Filters (`HasQueryFilter(e => e.TenantId == _currentTenant)`) for multi-tenant safety.
|
|
17
|
+
|
|
18
|
+
### 3. Anti-Forgery & TLS
|
|
19
|
+
* `TG-CSRF-001`: Ensure `[ValidateAntiForgeryToken]` or `[AutoValidateAntiforgeryToken]` is applied to POST/PUT/DELETE actions.
|
|
20
|
+
* Prohibit `DangerousAcceptAnyServerCertificateValidator`.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 🛠️ Safe Patterns Summary
|
|
25
|
+
|
|
26
|
+
```csharp
|
|
27
|
+
// Safe Entity Framework Parameterized Query
|
|
28
|
+
var user = await context.Users
|
|
29
|
+
.Where(u => u.Id == userId && u.TenantId == currentTenantId)
|
|
30
|
+
.FirstOrDefaultAsync();
|
|
31
|
+
|
|
32
|
+
// Safe Global Query Filter in DbContext
|
|
33
|
+
modelBuilder.Entity<Invoice>()
|
|
34
|
+
.HasQueryFilter(i => i.TenantId == _tenantProvider.GetTenantId());
|
|
35
|
+
|
|
36
|
+
// Safe Controller Security
|
|
37
|
+
[Authorize]
|
|
38
|
+
[ApiController]
|
|
39
|
+
[Route("api/[controller]")]
|
|
40
|
+
public class InvoicesController : ControllerBase { ... }
|
|
41
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: Go Security
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** A project is identified as a Go application (`go.mod`, `go.sum`, or Go source files detected).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛡️ Key Inspection Areas & Rules
|
|
8
|
+
|
|
9
|
+
### 1. Database & SQL Injection
|
|
10
|
+
* `TG-INPUT-002`: Ensure raw queries use parameterized placeholders (`?`, `$1`), never `fmt.Sprintf` or string concatenation.
|
|
11
|
+
* `TG-DB-004`: Enforce tenant isolation in GORM queries (`db.Where("tenant_id = ?", tenantID)`).
|
|
12
|
+
|
|
13
|
+
### 2. TLS & Network Security
|
|
14
|
+
* `TG-DIFF-001`: Prohibit `InsecureSkipVerify: true` in `tls.Config`. Always use valid root CA pools.
|
|
15
|
+
* `TG-SSRF-001`: Validate outbound URLs before issuing `http.Get` or `http.Post`.
|
|
16
|
+
|
|
17
|
+
### 3. Concurrency & Goroutine Safety
|
|
18
|
+
* `TG-BIZ-001`: Ensure context cancellation propagation (`ctx.Done()`) to prevent goroutine leaks.
|
|
19
|
+
* Use mutexes or channels to prevent data races on shared state.
|
|
20
|
+
|
|
21
|
+
### 4. Input Validation & Path Traversal
|
|
22
|
+
* `TG-INPUT-006`: Sanitize file paths with `filepath.Clean` and check `strings.HasPrefix(cleanPath, baseDir)`.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 🛠️ Safe Patterns Summary
|
|
27
|
+
|
|
28
|
+
```go
|
|
29
|
+
// Safe Parameterized Query
|
|
30
|
+
row := db.QueryRowContext(ctx, "SELECT id, email FROM users WHERE id = ? AND tenant_id = ?", userID, tenantID)
|
|
31
|
+
|
|
32
|
+
// Safe GORM Scoping
|
|
33
|
+
var invoice Invoice
|
|
34
|
+
result := db.Where("id = ? AND tenant_id = ?", invoiceID, currentTenantID).First(&invoice)
|
|
35
|
+
|
|
36
|
+
// Safe TLS Client
|
|
37
|
+
tlsConfig := &tls.Config{
|
|
38
|
+
MinVersion: tls.VersionTLS13,
|
|
39
|
+
}
|
|
40
|
+
client := &http.Client{Transport: &http.Transport{TLSClientConfig: tlsConfig}}
|
|
41
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: Java & Spring Security
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** A project is identified as a Java/Kotlin application (`pom.xml`, `build.gradle`, Spring Boot detected).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛡️ Key Inspection Areas & Rules
|
|
8
|
+
|
|
9
|
+
### 1. Spring Security & CSRF
|
|
10
|
+
* `TG-CSRF-001`: Prohibit `.csrf().disable()` or `AbstractHttpConfigurer::disable` on state-changing browser routes.
|
|
11
|
+
* `TG-PLATFORM-001`: Avoid `@CrossOrigin(origins = "*")` with `allowCredentials = "true"`.
|
|
12
|
+
|
|
13
|
+
### 2. JPA & Hibernate SQL Injection
|
|
14
|
+
* `TG-INPUT-002`: Use named parameters (`:param`) or `CriteriaBuilder`. Never concatenate strings into JPQL queries.
|
|
15
|
+
* `TG-DB-004`: Enforce tenant isolation via `@Filter` or explicit where clauses.
|
|
16
|
+
|
|
17
|
+
### 3. Insecure Deserialization & XML
|
|
18
|
+
* Prohibit `ObjectInputStream.readObject()` on untrusted input without look-ahead verification.
|
|
19
|
+
* Disable external entity resolution (`setFeature("http://apache.org/xml/features/disallow-doctype-decl", true)`).
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🛠️ Safe Patterns Summary
|
|
24
|
+
|
|
25
|
+
```java
|
|
26
|
+
// Safe JPA Query
|
|
27
|
+
@Query("SELECT u FROM User u WHERE u.id = :id AND u.tenantId = :tenantId")
|
|
28
|
+
Optional<User> findByIdAndTenantId(@Param("id") Long id, @Param("tenantId") String tenantId);
|
|
29
|
+
|
|
30
|
+
// Safe Spring Security Configuration
|
|
31
|
+
@Bean
|
|
32
|
+
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
|
33
|
+
http
|
|
34
|
+
.authorizeHttpRequests(auth -> auth
|
|
35
|
+
.requestMatchers("/public/**").permitAll()
|
|
36
|
+
.anyRequest().authenticated()
|
|
37
|
+
);
|
|
38
|
+
return http.build();
|
|
39
|
+
}
|
|
40
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# TorusGuard Universal Polyglot Security Matrix
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** Any language or framework is detected. Maps universal security invariants across major programming language ecosystems.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛡️ Cross-Language Invariant Mappings
|
|
8
|
+
|
|
9
|
+
| Rule Family | Python | TypeScript / Node.js | Go | Rust | Java / Kotlin | C# / .NET |
|
|
10
|
+
|---|---|---|---|---|---|---|
|
|
11
|
+
| **TG-SEC (Secrets)** | `os.environ["KEY"]` | `process.env.KEY` | `os.Getenv("KEY")` | `std::env::var("KEY")` | `System.getenv("KEY")` | `Environment.GetEnvironmentVariable()` |
|
|
12
|
+
| **TG-DB (SQL Injection)** | `%s` / ORM bound | `$1` / Prisma / Drizzle | `?` / `$1` / GORM `?` | `sqlx::query!` / Diesel | Named parameters `:param` | `@p0` / `FromSqlInterpolated` |
|
|
13
|
+
| **TG-DB-004 (Tenant Scope)** | `.filter(tenant=...)` | `where: { tenantId }` | `.Where("tenant_id = ?", tid)` | `filter(tenant_id.eq(tid))` | `WHERE e.tenantId = :tid` | `.Where(x => x.TenantId == tid)` |
|
|
14
|
+
| **TG-AUTH (Access Control)** | `@login_required` / Depends | Middleware auth / Guards | Middleware handlers | Tower layer / extractors | `@PreAuthorize` / Spring Sec | `[Authorize]` attributes |
|
|
15
|
+
| **TG-CSRF (Request Forgery)** | CSRF Middleware | SameSite / csurf | Gorilla CSRF | Anti-CSRF token middleware | Spring Security CSRF | `[ValidateAntiForgeryToken]` |
|
|
16
|
+
| **TG-DIFF (Bypass Comments)** | No `# nosec` | No `// nosec` | No `/* nosec */` | No `#![allow(unsafe)]` | No `@SuppressWarnings` | No pragma disable |
|
|
17
|
+
| **TG-DIFF (TLS Verification)** | No `verify=False` | No `rejectUnauthorized:false` | No `InsecureSkipVerify: true` | No `danger_accept_invalid_certs`| No `TrustAllStrategy` | No `DangerousAcceptAny...` |
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 🚀 Polyglot Hardening Rules of Thumb
|
|
22
|
+
|
|
23
|
+
1. **Parameterize Everything:** Never concatenate raw user input into SQL, shell commands, LDAP filters, or template strings, regardless of language.
|
|
24
|
+
2. **Fail Closed on Auth:** Default all endpoints to authenticated; explicitly mark public routes rather than remembering to protect private ones.
|
|
25
|
+
3. **Strict Bounds:** Keep remediation diffs minimal ($\le 35$ additions, $\le 25$ deletions) to ensure auditability across all codebases.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: Rust Security
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** A project is identified as a Rust application (`Cargo.toml` or `.rs` files detected).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛡️ Key Inspection Areas & Rules
|
|
8
|
+
|
|
9
|
+
### 1. Memory Safety & Unsafe Blocks
|
|
10
|
+
* `TG-INPUT-003`: Audit and restrict `unsafe { ... }` blocks. Must include a `// SAFETY:` rationale comment.
|
|
11
|
+
* Never disable standard borrow checker lints via `#![allow(unsafe_code)]`.
|
|
12
|
+
|
|
13
|
+
### 2. Database & SQL Queries
|
|
14
|
+
* `TG-INPUT-002`: Use compile-time checked `sqlx::query!` or Diesel query builder methods.
|
|
15
|
+
* `TG-DB-004`: Enforce tenant filtering in queries (`filter(tenant_id.eq(current_tenant_id))`).
|
|
16
|
+
|
|
17
|
+
### 3. Outbound Requests & TLS
|
|
18
|
+
* `TG-DIFF-001`: Prohibit `danger_accept_invalid_certs(true)` in `reqwest::ClientBuilder`.
|
|
19
|
+
* `TG-SSRF-001`: Enforce IP allowlists before dispatching network calls.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🛠️ Safe Patterns Summary
|
|
24
|
+
|
|
25
|
+
```rust
|
|
26
|
+
// Safe sqlx Parameterized Query
|
|
27
|
+
let user = sqlx::query_as!(
|
|
28
|
+
User,
|
|
29
|
+
"SELECT id, email FROM users WHERE id = $1 AND tenant_id = $2",
|
|
30
|
+
user_id,
|
|
31
|
+
current_tenant_id
|
|
32
|
+
)
|
|
33
|
+
.fetch_one(&pool)
|
|
34
|
+
.await?;
|
|
35
|
+
|
|
36
|
+
// Safe reqwest Client (Strict TLS)
|
|
37
|
+
let client = reqwest::Client::builder()
|
|
38
|
+
.timeout(std::time::Duration::from_secs(10))
|
|
39
|
+
.build()?;
|
|
40
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Retain custom rules directory
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# TorusGuard Custom Rules Directory
|
|
2
|
+
|
|
3
|
+
Place your custom organization-specific, framework-specific, or proprietary library rules here.
|
|
4
|
+
Any markdown files (`*.md`) or JSON files (`*.json`) placed in this directory will be automatically indexed during `/torusguard-audit` and finding scoring.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Example Custom Rule: `TG-CUSTOM-001.md`
|
|
9
|
+
|
|
10
|
+
```markdown
|
|
11
|
+
# TG-CUSTOM-001: Require Organization UUID on All Multi-Tenant Queries
|
|
12
|
+
|
|
13
|
+
**Rule ID:** TG-CUSTOM-001
|
|
14
|
+
**Severity:** High
|
|
15
|
+
**Category:** database-safety
|
|
16
|
+
**Confidence Base:** 85
|
|
17
|
+
|
|
18
|
+
### Description
|
|
19
|
+
Ensure all database operations on multi-tenant tables enforce explicit `org_id` or `tenant_id` boundaries.
|
|
20
|
+
|
|
21
|
+
### Unsafe Pattern
|
|
22
|
+
```python
|
|
23
|
+
db.execute("SELECT * FROM invoices WHERE status = 'paid'")
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Safe Remediation
|
|
27
|
+
```python
|
|
28
|
+
db.execute("SELECT * FROM invoices WHERE status = 'paid' AND org_id = %s", [current_org_id])
|
|
29
|
+
```
|
|
30
|
+
```
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://torusguard.dev/schemas/golden-recipe.schema.json",
|
|
4
|
+
"title": "TorusGuard Golden Fix Recipe Schema",
|
|
5
|
+
"description": "Schema for reusable, verified AST remediation code snippets distilled from passing security patches.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": [
|
|
8
|
+
"recipe_id",
|
|
9
|
+
"rule_id",
|
|
10
|
+
"file_type",
|
|
11
|
+
"before_snippet",
|
|
12
|
+
"after_snippet",
|
|
13
|
+
"diff_snippet",
|
|
14
|
+
"ponytail_metrics",
|
|
15
|
+
"verified_count",
|
|
16
|
+
"last_verified"
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"recipe_id": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"pattern": "^recipe-[A-Za-z0-9_-]+$"
|
|
22
|
+
},
|
|
23
|
+
"rule_id": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"pattern": "^TG-[A-Z]+-[0-9]{3}$"
|
|
26
|
+
},
|
|
27
|
+
"file_type": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "File extension or language identifier (e.g., .py, .ts, .js)"
|
|
30
|
+
},
|
|
31
|
+
"framework": {
|
|
32
|
+
"type": ["string", "null"],
|
|
33
|
+
"description": "Target web framework (e.g., Django, FastAPI, Next.js)"
|
|
34
|
+
},
|
|
35
|
+
"description": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "Human-readable summary of the fix strategy"
|
|
38
|
+
},
|
|
39
|
+
"before_snippet": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "Vulnerable code pattern before remediation"
|
|
42
|
+
},
|
|
43
|
+
"after_snippet": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "Remediated code pattern adhering to Ponytail bounds"
|
|
46
|
+
},
|
|
47
|
+
"diff_snippet": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"description": "Unified diff snippet representing the surgical fix"
|
|
50
|
+
},
|
|
51
|
+
"ponytail_metrics": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"required": ["additions", "deletions"],
|
|
54
|
+
"properties": {
|
|
55
|
+
"additions": {
|
|
56
|
+
"type": "integer",
|
|
57
|
+
"maximum": 35
|
|
58
|
+
},
|
|
59
|
+
"deletions": {
|
|
60
|
+
"type": "integer",
|
|
61
|
+
"maximum": 25
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"verified_count": {
|
|
66
|
+
"type": "integer",
|
|
67
|
+
"minimum": 1
|
|
68
|
+
},
|
|
69
|
+
"last_verified": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"format": "date-time"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"additionalProperties": false
|
|
75
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "torusguard-memory-context.schema.json",
|
|
4
|
+
"title": "TorusGuard Memory Context Window",
|
|
5
|
+
"description": "Pre-computed, token-budgeted context window for AI agent consumption formatted as structured JSON cards.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["version", "generated_at", "token_estimate", "max_token_budget", "project_profile", "cards"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"version": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "TorusGuard engine version (e.g., 1.0.0)."
|
|
12
|
+
},
|
|
13
|
+
"generated_at": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"format": "date-time",
|
|
16
|
+
"description": "ISO 8601 UTC timestamp when this context window was computed."
|
|
17
|
+
},
|
|
18
|
+
"token_estimate": {
|
|
19
|
+
"type": "integer",
|
|
20
|
+
"minimum": 0,
|
|
21
|
+
"description": "Estimated token count of this context document."
|
|
22
|
+
},
|
|
23
|
+
"max_token_budget": {
|
|
24
|
+
"type": "integer",
|
|
25
|
+
"default": 2000,
|
|
26
|
+
"description": "Maximum allowed tokens for agent context injection (default: 2000)."
|
|
27
|
+
},
|
|
28
|
+
"project_profile": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"required": ["stack", "total_events", "active_patterns_count"],
|
|
31
|
+
"properties": {
|
|
32
|
+
"stack": {
|
|
33
|
+
"type": "array",
|
|
34
|
+
"items": { "type": "string" },
|
|
35
|
+
"description": "Detected technology stack frameworks/languages."
|
|
36
|
+
},
|
|
37
|
+
"total_events": {
|
|
38
|
+
"type": "integer",
|
|
39
|
+
"minimum": 0
|
|
40
|
+
},
|
|
41
|
+
"active_patterns_count": {
|
|
42
|
+
"type": "integer",
|
|
43
|
+
"minimum": 0
|
|
44
|
+
},
|
|
45
|
+
"fix_rate_percentage": {
|
|
46
|
+
"type": ["number", "null"],
|
|
47
|
+
"minimum": 0,
|
|
48
|
+
"maximum": 100
|
|
49
|
+
},
|
|
50
|
+
"top_vulnerabilities": {
|
|
51
|
+
"type": "array",
|
|
52
|
+
"items": { "type": "string" }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"cards": {
|
|
57
|
+
"type": "array",
|
|
58
|
+
"description": "Ordered list of high-priority intelligence cards for LLM grounding.",
|
|
59
|
+
"items": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"required": ["card_id", "card_type", "priority", "title", "summary", "card_data"],
|
|
62
|
+
"properties": {
|
|
63
|
+
"card_id": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"description": "Unique card identifier (e.g., CARD-001)."
|
|
66
|
+
},
|
|
67
|
+
"card_type": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"enum": ["pattern", "profile", "regression_watch", "false_positive", "fix_idiom"],
|
|
70
|
+
"description": "Semantic category of this context card."
|
|
71
|
+
},
|
|
72
|
+
"priority": {
|
|
73
|
+
"type": "integer",
|
|
74
|
+
"minimum": 1,
|
|
75
|
+
"maximum": 100,
|
|
76
|
+
"description": "Rank order priority (higher = more relevant/critical)."
|
|
77
|
+
},
|
|
78
|
+
"title": {
|
|
79
|
+
"type": "string",
|
|
80
|
+
"description": "Short, human-readable and agent-scannable card title."
|
|
81
|
+
},
|
|
82
|
+
"summary": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"description": "One-line operational summary for rapid agent reasoning."
|
|
85
|
+
},
|
|
86
|
+
"card_data": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"description": "Structured card payload containing rule_id, fix_strategy, confidence, affected_files, etc.",
|
|
89
|
+
"additionalProperties": true
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "torusguard-memory-event.schema.json",
|
|
4
|
+
"title": "TorusGuard Memory Event",
|
|
5
|
+
"description": "Schema for individual memory events recorded during audit/fix/recheck cycles.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["event_id", "event_type", "timestamp", "version"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"event_id": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Unique event identifier (UUID v4 or timestamp-based)."
|
|
12
|
+
},
|
|
13
|
+
"event_type": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"enum": ["audit_finding", "fix_applied", "fix_verified", "false_positive", "pattern_learned", "stack_changed"],
|
|
16
|
+
"description": "Category of security event."
|
|
17
|
+
},
|
|
18
|
+
"timestamp": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"format": "date-time",
|
|
21
|
+
"description": "ISO 8601 UTC timestamp."
|
|
22
|
+
},
|
|
23
|
+
"version": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "TorusGuard version that recorded this event."
|
|
26
|
+
},
|
|
27
|
+
"rule_id": {
|
|
28
|
+
"type": ["string", "null"],
|
|
29
|
+
"description": "TorusGuard rule ID (e.g., TG-DB-004)."
|
|
30
|
+
},
|
|
31
|
+
"file_path": {
|
|
32
|
+
"type": ["string", "null"],
|
|
33
|
+
"description": "Relative file path within the project."
|
|
34
|
+
},
|
|
35
|
+
"line_number": {
|
|
36
|
+
"type": ["integer", "null"],
|
|
37
|
+
"description": "Line number of the finding."
|
|
38
|
+
},
|
|
39
|
+
"severity": {
|
|
40
|
+
"type": ["string", "null"],
|
|
41
|
+
"enum": ["critical", "high", "medium", "low", "info", null]
|
|
42
|
+
},
|
|
43
|
+
"confidence_score": {
|
|
44
|
+
"type": ["integer", "null"],
|
|
45
|
+
"minimum": 0,
|
|
46
|
+
"maximum": 100
|
|
47
|
+
},
|
|
48
|
+
"code_hash": {
|
|
49
|
+
"type": ["string", "null"],
|
|
50
|
+
"description": "SHA-256 hash of the relevant code snippet for pattern matching."
|
|
51
|
+
},
|
|
52
|
+
"fix_strategy": {
|
|
53
|
+
"type": ["string", "null"],
|
|
54
|
+
"description": "Human-readable description of the fix approach used."
|
|
55
|
+
},
|
|
56
|
+
"verification_result": {
|
|
57
|
+
"type": ["string", "null"],
|
|
58
|
+
"enum": ["fixed", "regressed", "partial", "not_tested", null]
|
|
59
|
+
},
|
|
60
|
+
"suppression_reason": {
|
|
61
|
+
"type": ["string", "null"],
|
|
62
|
+
"description": "Reason for false positive suppression."
|
|
63
|
+
},
|
|
64
|
+
"metadata": {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"description": "Additional event-specific metadata.",
|
|
67
|
+
"additionalProperties": true
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "torusguard-memory-pattern.schema.json",
|
|
4
|
+
"title": "TorusGuard Memory Pattern",
|
|
5
|
+
"description": "Schema for distilled security patterns extracted from raw events. Patterns represent recurring fix strategies, vulnerability classes, and project-specific security idioms.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["pattern_id", "rule_id", "pattern_type", "confidence", "occurrences", "first_seen", "last_seen"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"pattern_id": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Unique pattern identifier (PAT-NNN)."
|
|
12
|
+
},
|
|
13
|
+
"rule_id": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "TorusGuard rule ID this pattern relates to."
|
|
16
|
+
},
|
|
17
|
+
"pattern_type": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"enum": ["recurring_fix", "common_vulnerability", "false_positive_class", "regression_watch", "security_idiom"],
|
|
20
|
+
"description": "Category of the distilled pattern."
|
|
21
|
+
},
|
|
22
|
+
"description": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "Human-readable summary of the pattern."
|
|
25
|
+
},
|
|
26
|
+
"fix_strategy": {
|
|
27
|
+
"type": ["string", "null"],
|
|
28
|
+
"description": "The preferred fix approach observed across multiple occurrences."
|
|
29
|
+
},
|
|
30
|
+
"confidence": {
|
|
31
|
+
"type": "integer",
|
|
32
|
+
"minimum": 0,
|
|
33
|
+
"maximum": 100,
|
|
34
|
+
"description": "Pattern confidence (amplified by repeated confirmations, decayed by TTL)."
|
|
35
|
+
},
|
|
36
|
+
"occurrences": {
|
|
37
|
+
"type": "integer",
|
|
38
|
+
"minimum": 1,
|
|
39
|
+
"description": "Number of times this pattern has been observed."
|
|
40
|
+
},
|
|
41
|
+
"affected_files": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"items": { "type": "string" },
|
|
44
|
+
"description": "List of relative file paths where this pattern has been observed."
|
|
45
|
+
},
|
|
46
|
+
"first_seen": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"format": "date-time"
|
|
49
|
+
},
|
|
50
|
+
"last_seen": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"format": "date-time"
|
|
53
|
+
},
|
|
54
|
+
"decay_checkpoint": {
|
|
55
|
+
"type": ["string", "null"],
|
|
56
|
+
"format": "date-time",
|
|
57
|
+
"description": "Last timestamp when this pattern's confidence was reconfirmed or decayed."
|
|
58
|
+
},
|
|
59
|
+
"source_events": {
|
|
60
|
+
"type": "array",
|
|
61
|
+
"items": { "type": "string" },
|
|
62
|
+
"description": "List of event_ids that contributed to this pattern."
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|