Skip to content

Commit e4d1ea1

Browse files
feat: Add MkDocs documentation, GitHub Actions, and CONTRIBUTING guide
- Add mkdocs.yml with Material theme configuration - Create docs/ structure with getting-started guides - Add skills catalog index page - Add GitHub Actions for: - Automated skill catalog generation on push - MkDocs deployment to GitHub Pages - Add scripts/generate-skill-index.py for dynamic skill discovery - Add CONTRIBUTING.md with skill creation template - Add changelog.md Docs will be published to: https://developerscoffee.github.io/java-cwe-security-skills/
1 parent b54d72d commit e4d1ea1

12 files changed

Lines changed: 1301 additions & 0 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Deploy MkDocs to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'docs/**'
9+
- 'mkdocs.yml'
10+
- 'cwe-*/**'
11+
- '.github/workflows/deploy-docs.yml'
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: write
16+
pages: write
17+
id-token: write
18+
19+
jobs:
20+
generate-skill-index:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.11'
29+
30+
- name: Generate Skill Index
31+
run: |
32+
python scripts/generate-skill-index.py
33+
34+
- name: Upload generated docs
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: generated-docs
38+
path: docs/skills/
39+
40+
deploy:
41+
needs: generate-skill-index
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Download generated docs
47+
uses: actions/download-artifact@v4
48+
with:
49+
name: generated-docs
50+
path: docs/skills/
51+
52+
- name: Set up Python
53+
uses: actions/setup-python@v5
54+
with:
55+
python-version: '3.11'
56+
57+
- name: Install MkDocs and dependencies
58+
run: |
59+
pip install mkdocs-material pymdown-extensions
60+
61+
- name: Build MkDocs site
62+
run: mkdocs build --strict
63+
64+
- name: Deploy to GitHub Pages
65+
uses: peaceiris/actions-gh-pages@v4
66+
with:
67+
github_token: ${{ secrets.GITHUB_TOKEN }}
68+
publish_dir: ./site
69+
publish_branch: gh-pages
70+
force_orphan: true
71+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Generate CWE Skill Catalog
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'cwe-*/**'
9+
pull_request:
10+
paths:
11+
- 'cwe-*/**'
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
generate-catalog:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.11'
29+
30+
- name: Install dependencies
31+
run: pip install pyyaml
32+
33+
- name: Generate skill catalog
34+
run: python scripts/generate-skill-index.py
35+
36+
- name: Update index.md
37+
run: |
38+
if [ -f "docs/skills/_generated_index.md" ]; then
39+
mv docs/skills/_generated_index.md docs/skills/index.md
40+
fi
41+
42+
- name: Commit changes
43+
if: github.event_name == 'push'
44+
run: |
45+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
46+
git config --local user.name "github-actions[bot]"
47+
git add docs/skills/
48+
git diff --quiet && git diff --staged --quiet || git commit -m "🤖 Auto-generate skill catalog [skip ci]"
49+
git push || echo "No changes to push"
50+

CONTRIBUTING.md

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
# Contributing to Java CWE Security Skills
2+
3+
Thank you for your interest in contributing! This guide explains how to create new CWE security skills.
4+
5+
---
6+
7+
## 📋 Prerequisites
8+
9+
- Familiarity with Java security vulnerabilities
10+
- Understanding of MITRE CWE framework
11+
- Knowledge of secure coding practices
12+
13+
---
14+
15+
## 🗂️ Skill Folder Structure
16+
17+
Each skill lives in its own folder following this naming convention:
18+
19+
```
20+
cwe-{number}-{short-name}/
21+
└── SKILL.md
22+
```
23+
24+
**Examples:**
25+
- `cwe-89-sql-injection/`
26+
- `cwe-79-xss/`
27+
- `cwe-327-weak-cryptography/`
28+
29+
---
30+
31+
## 📝 SKILL.md Template
32+
33+
Every skill must contain a `SKILL.md` file with this structure:
34+
35+
```markdown
36+
---
37+
name: cwe-{number}-{short-name}
38+
description: Brief description of the vulnerability
39+
version: 1.0.0
40+
tags:
41+
- security
42+
- java
43+
- cwe-{number}
44+
- {category}
45+
---
46+
47+
# CWE-{number} {Official CWE Name}
48+
49+
## Description
50+
51+
{Detailed description of the vulnerability}
52+
53+
Reference: https://cwe.mitre.org/data/definitions/{number}.html
54+
55+
**OWASP Category**: {OWASP Top 10 category if applicable}
56+
57+
---
58+
59+
## Vulnerable Pattern
60+
61+
### ❌ Example 1
62+
63+
```java
64+
// Vulnerable code example
65+
```
66+
67+
### ❌ Example 2
68+
69+
```java
70+
// Another vulnerable pattern
71+
```
72+
73+
---
74+
75+
## Deterministic Fix
76+
77+
### ✅ Secure Implementation
78+
79+
```java
80+
// Correct, secure code
81+
```
82+
83+
---
84+
85+
## Detection Pattern
86+
87+
```bash
88+
# grep/regex commands to find vulnerable code
89+
grep -rn "pattern" --include="*.java" src/
90+
```
91+
92+
---
93+
94+
## Remediation Steps
95+
96+
1. Step one
97+
2. Step two
98+
3. Step three
99+
100+
---
101+
102+
## Key Imports
103+
104+
```java
105+
import required.packages;
106+
```
107+
108+
---
109+
110+
## Verification
111+
112+
- Re-run SAST scan
113+
- Test with attack payloads
114+
- Verify functionality preserved
115+
116+
---
117+
118+
## References
119+
120+
- [CWE-{number}](https://cwe.mitre.org/data/definitions/{number}.html)
121+
- [OWASP Cheat Sheet](link)
122+
```
123+
124+
---
125+
126+
## 🚀 Creating a New Skill
127+
128+
### Step 1: Choose a CWE
129+
130+
Pick a CWE from the [MITRE CWE List](https://cwe.mitre.org/data/definitions/699.html) that:
131+
- Affects Java applications
132+
- Has deterministic remediation patterns
133+
- Is not already covered in this repository
134+
135+
### Step 2: Create the folder
136+
137+
```bash
138+
mkdir cwe-XXX-short-name
139+
touch cwe-XXX-short-name/SKILL.md
140+
```
141+
142+
### Step 3: Research the vulnerability
143+
144+
- Read the official CWE description
145+
- Find vulnerable code examples
146+
- Document the secure fix pattern
147+
148+
### Step 4: Write the SKILL.md
149+
150+
Use the template above. Include:
151+
- At least 2 vulnerable code examples
152+
- At least 1 secure implementation
153+
- grep commands for detection
154+
- Step-by-step remediation
155+
156+
### Step 5: Test your skill
157+
158+
Verify the skill works with an AI coding assistant:
159+
160+
```
161+
Fix CWE-XXX in this code: [paste vulnerable code]
162+
```
163+
164+
---
165+
166+
## ✅ Pull Request Checklist
167+
168+
- [ ] Folder follows naming convention: `cwe-{number}-{name}/`
169+
- [ ] SKILL.md uses the required template
170+
- [ ] YAML frontmatter is valid
171+
- [ ] At least 2 vulnerable code examples
172+
- [ ] At least 1 secure implementation
173+
- [ ] Detection commands work
174+
- [ ] References include CWE link
175+
- [ ] Tested with AI assistant
176+
177+
---
178+
179+
## 📌 Code Style
180+
181+
- Use 4-space indentation in Java examples
182+
- Include complete, compilable code snippets
183+
- Add comments explaining the vulnerability/fix
184+
- Use realistic, production-like examples
185+
186+
---
187+
188+
## 🏷️ Tagging Guidelines
189+
190+
Use these standard tags in your SKILL.md frontmatter:
191+
192+
| Tag | When to use |
193+
|-----|-------------|
194+
| `security` | Always |
195+
| `java` | Always |
196+
| `cwe-{number}` | Always |
197+
| `injection` | SQL, XSS, Command, etc. |
198+
| `cryptography` | Crypto-related |
199+
| `authentication` | Auth/session issues |
200+
| `access-control` | Authorization issues |
201+
202+
---
203+
204+
## 💬 Questions?
205+
206+
Open an issue or discussion on GitHub.
207+

0 commit comments

Comments
 (0)