Skip to content

Commit f7dbea4

Browse files
thschaffrthschaffr
authored andcommitted
This commit surfaces rule frontmatter tags in IDE outputs and adds a tag-to-rule mapping table to the generated SKILL.md.
Tags are already validated in rule frontmatter (utils.validate_tags) and exposed on ProcessedRule/ConversionResult, but they were not propagated to any IDE-format output or to the generated SKILL.md. This change makes the existing tag data actually usable downstream. Format changes (tags appended to YAML frontmatter when present): - cursor.py: tags: [authentication, web] - copilot.py: tags: [authentication, web] - windsurf.py: tags: [authentication, web] - antigravity.py: tags: [authentication, web] - agentskills.py: expanded YAML list (inherited by opencode, codex, openclaw, hermes, claude formats) SKILL.md template / generator: - Add <!-- TAG_MAPPINGS_START --> / <!-- TAG_MAPPINGS_END --> markers mirroring the existing language-mapping block - New update_tag_mappings() renders a "Security Context (Tag) -> Rules" table from the per-run tag_to_rules dict; falls back silently when the markers are absent so older templates still build - Add a new section to the skill workflow text that calls out tag-based selection alongside the existing language-based selection Regenerated skills/software-security/ artifacts to match the new pipeline (committed because they ship as the plugin payload). No change to tag_mappings.py (avoids overlap with PR cosai-oasis#80). No change to validation behavior; validate_unified_rules.py already rejects unknown tags.
1 parent dddb5c3 commit f7dbea4

22 files changed

Lines changed: 130 additions & 10 deletions

skills/software-security/SKILL.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,20 @@ When writing or reviewing code:
2424
- `codeguard-1-hardcoded-credentials.md` - Never hardcode secrets, passwords, API keys, or tokens
2525
- `codeguard-1-crypto-algorithms.md` - Use only modern, secure cryptographic algorithms
2626
- `codeguard-1-digital-certificates.md` - Validate and manage digital certificates securely
27-
2. Context-Specific Rules: Apply rules from /rules directory based on the language of the feature being implemented using the table given below:
27+
2. Tag-Based Rules: When you identify any of these security contexts in the code, apply ALL rules with the matching tag:
28+
29+
30+
| Security Context (Tag) | Rule Files to Apply |
31+
|------------------------|---------------------|
32+
| authentication | codeguard-0-authentication-mfa.md, codeguard-0-session-management-and-cookies.md |
33+
| data-security | codeguard-0-additional-cryptography.md, codeguard-0-data-storage.md |
34+
| infrastructure | codeguard-0-cloud-orchestration-kubernetes.md, codeguard-0-data-storage.md, codeguard-0-devops-ci-cd-containers.md, codeguard-0-iac-security.md |
35+
| privacy | codeguard-0-logging.md, codeguard-0-privacy-data-protection.md |
36+
| secrets | codeguard-0-additional-cryptography.md, codeguard-1-digital-certificates.md, codeguard-1-hardcoded-credentials.md |
37+
| web | codeguard-0-api-web-services.md, codeguard-0-authentication-mfa.md, codeguard-0-client-side-web-security.md, codeguard-0-input-validation-injection.md, codeguard-0-session-management-and-cookies.md |
38+
39+
40+
3. Language-Specific Rules: Apply rules from /rules directory based on the programming language of the feature being implemented using the table given below:
2841

2942

3043
| Language | Rule Files to Apply |
@@ -55,7 +68,7 @@ When writing or reviewing code:
5568
| yaml | codeguard-0-additional-cryptography.md, codeguard-0-api-web-services.md, codeguard-0-authorization-access-control.md, codeguard-0-cloud-orchestration-kubernetes.md, codeguard-0-data-storage.md, codeguard-0-devops-ci-cd-containers.md, codeguard-0-framework-and-languages.md, codeguard-0-iac-security.md, codeguard-0-logging.md, codeguard-0-privacy-data-protection.md, codeguard-0-supply-chain-security.md |
5669

5770

58-
3. Proactive Security: Don't just avoid vulnerabilities-actively implement secure patterns:
71+
4. Proactive Security: Don't just avoid vulnerabilities-actively implement secure patterns:
5972
- Use parameterized queries for database access
6073
- Validate and sanitize all user input
6174
- Apply least-privilege principles
@@ -71,8 +84,8 @@ When generating or reviewing code, follow this workflow:
7184
### 1. Initial Security Check
7285
Before writing any code:
7386
- Check: Will this handle credentials? → Apply codeguard-1-hardcoded-credentials
87+
- Check: What security tags apply? → Load all rules with matching tags (e.g., "authentication", "web", "secrets")
7488
- Check: What language am I using? → Identify applicable language-specific rules
75-
- Check: What security domains are involved? → Load relevant rule files
7689

7790
### 2. Code Generation
7891
While writing code:

skills/software-security/rules/codeguard-0-additional-cryptography.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ languages:
1515
- xml
1616
- yaml
1717
alwaysApply: false
18+
tags:
19+
- data-security
20+
- secrets
1821
---
1922

2023
rule_id: codeguard-0-additional-cryptography

skills/software-security/rules/codeguard-0-api-web-services.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ languages:
1212
- xml
1313
- yaml
1414
alwaysApply: false
15+
tags:
16+
- web
1517
---
1618

1719
rule_id: codeguard-0-api-web-services

skills/software-security/rules/codeguard-0-authentication-mfa.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ languages:
1313
- swift
1414
- typescript
1515
alwaysApply: false
16+
tags:
17+
- authentication
18+
- web
1619
---
1720

1821
rule_id: codeguard-0-authentication-mfa

skills/software-security/rules/codeguard-0-client-side-web-security.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ languages:
88
- typescript
99
- vlang
1010
alwaysApply: false
11+
tags:
12+
- web
1113
---
1214

1315
rule_id: codeguard-0-client-side-web-security

skills/software-security/rules/codeguard-0-cloud-orchestration-kubernetes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ languages:
44
- javascript
55
- yaml
66
alwaysApply: false
7+
tags:
8+
- infrastructure
79
---
810

911
rule_id: codeguard-0-cloud-orchestration-kubernetes

skills/software-security/rules/codeguard-0-data-storage.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ languages:
66
- sql
77
- yaml
88
alwaysApply: false
9+
tags:
10+
- data-security
11+
- infrastructure
912
---
1013

1114
rule_id: codeguard-0-data-storage

skills/software-security/rules/codeguard-0-devops-ci-cd-containers.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ languages:
88
- xml
99
- yaml
1010
alwaysApply: false
11+
tags:
12+
- infrastructure
1113
---
1214

1315
rule_id: codeguard-0-devops-ci-cd-containers

skills/software-security/rules/codeguard-0-iac-security.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ languages:
99
- shell
1010
- yaml
1111
alwaysApply: false
12+
tags:
13+
- infrastructure
1214
---
1315

1416
rule_id: codeguard-0-iac-security

skills/software-security/rules/codeguard-0-input-validation-injection.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ languages:
1515
- sql
1616
- typescript
1717
alwaysApply: false
18+
tags:
19+
- web
1820
---
1921

2022
rule_id: codeguard-0-input-validation-injection

0 commit comments

Comments
 (0)