Skip to content

Commit eff1b08

Browse files
committed
Enhance README.md with new features including email notifications for critical findings and detailed configuration options. Update EXTENDING.md to encourage contributions for specific Semgrep rules. Revise core_critical_rules.mdc to enforce file size limits for scripts. Improve task documentation in task_6.md and task_7.md by marking completed items. Refactor generate-html-report.py to streamline report generation and improve HTML output sections for ZAP, Semgrep, and Trivy. Update baseline.conf for API-specific adjustments in ZAP scanning. These changes aim to improve usability, documentation clarity, and security scanning capabilities.
1 parent 295f7ca commit eff1b08

18 files changed

Lines changed: 869 additions & 359 deletions

.cursor/rules/core_critical_rules.mdc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The AI should do as much as possible. Minimize user interaction.
1919
* The user should only provide the task and minimal feedback.
2020
* The AI should generate all code and solutions.
2121
* The user should not interfere with the AI's work.
22+
* Each file should not exceed 200 lines. If a script is to big , try to refactor and split!
2223

2324
**Prohibitions:**
2425
* No user-generated code or solutions.

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,37 @@ SecuLite is an all-in-one security toolkit for modern software projects. It comb
1919
- **Unified Reporting:** Results as TXT/JSON, clearly aggregated
2020
- **Extensible & Open:** Easily add your own rules, tools, workflows
2121
- **CI/CD-ready:** Docker-based, GitHub Actions workflow included
22+
- **Email Notifications:** Optional email alerts for critical/high severity findings.
23+
24+
---
25+
26+
## ⚙️ Configuration
27+
28+
SecuLite can be configured using environment variables. Create a `.env` file in the project root or set them in your shell.
29+
30+
### Core Configuration
31+
32+
- `ZAP_TARGET`: The target URL for ZAP to scan (e.g., `http://localhost:8000`). Can also be passed as an argument to `security-check.sh`.
33+
- `HTML_REPORT`: Set to `1` to generate an HTML report (default is `0` for console-only, though the Docker setup typically generates it).
34+
35+
### Email Notification Configuration (Optional)
36+
37+
To enable email notifications for critical/high severity findings, set the following environment variables:
38+
39+
- `NOTIFICATION_EMAIL_RECIPIENT`: Email address to send notifications to.
40+
- `SMTP_SERVER`: SMTP server address (e.g., `smtp.example.com`).
41+
- `SMTP_PORT`: SMTP server port (e.g., `587` or `465`).
42+
- `SMTP_USER`: Username for SMTP authentication.
43+
- `SMTP_PASSWORD`: Password for SMTP authentication.
44+
- `SMTP_SENDER_EMAIL`: The "From" email address for notifications (defaults to `SMTP_USER` if not set).
45+
46+
### LLM Provider Configuration (Optional)
47+
48+
For AI-powered explanations of findings in the HTML report:
49+
50+
- `LLM_PROVIDER`: Choose from `openai`, `gemini`, `huggingface`, `groq`, `mistral`, `anthropic` (defaults to `openai`).
51+
- `<PROVIDER>_API_KEY`: API key for the chosen provider (e.g., `OPENAI_API_KEY`).
52+
- `<PROVIDER>_MODEL`: Specific model for the chosen provider (e.g., `OPENAI_MODEL=gpt-4`).
2253

2354
---
2455

@@ -61,6 +92,21 @@ cd SimpleSecCheck
6192
```
6293
- WebUI available at: [http://localhost:8080](http://localhost:8080)
6394

95+
## 🛠️ Available Scans & Rules
96+
97+
SecuLite utilizes the following tools and rule categories:
98+
99+
- **OWASP ZAP:** Web application vulnerabilities (baseline scan).
100+
- **Semgrep:** Static code analysis for:
101+
- Code Bugs (`rules/code-bugs.yml`)
102+
- Secrets Detection (`rules/secrets.yml`)
103+
- Prompt Injection (`rules/prompt-injection.yml`)
104+
- API Security (`rules/api-security.yml`)
105+
- LLM/AI Security (`rules/llm-ai-security.yml`)
106+
- **Trivy:** Dependency and container image scanning.
107+
108+
---
109+
64110
## 🤝 Contributing & Extending
65111

66112
- See [`doc/EXTENDING.md`](doc/EXTENDING.md) for adding your own rules, tools, workflows.

conf/fp_whitelist.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[
2+
{
3+
"tool": "semgrep",
4+
"check_id": "generic.secrets.security.hardcoded-secret.hardcoded-secret",
5+
"path_pattern": "src/examples/.*",
6+
"line_content_pattern": "just_an_example_key",
7+
"reason": "This is an example key in a demonstration file, not a real secret."
8+
},
9+
{
10+
"tool": "semgrep",
11+
"check_id": "python.django.security.debug-true.debug-true",
12+
"path_pattern": "settings_dev.py",
13+
"reason": "DEBUG=True is intentional for development settings file."
14+
},
15+
{
16+
"tool": "zap",
17+
"plugin_id": "10021",
18+
"uri_pattern": "http://localhost:8000/test-endpoints/no-x-content-type-options",
19+
"parameter_pattern": null,
20+
"reason": "Test endpoint intentionally missing X-Content-Type-Options for specific test case."
21+
},
22+
{
23+
"tool": "trivy",
24+
"vulnerability_id": "CVE-2020-12345",
25+
"package_name": "example-lib",
26+
"package_version_pattern": "1.0.*",
27+
"reason": "This CVE is for a feature not used in our project, risk accepted after review for v1.0.x."
28+
}
29+
]

docs/EXTENDING.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
- **Semgrep:**
55
- Place new YAML rule files in `/rules/`.
66
- Use descriptive filenames (e.g., `injection-detection.yml`).
7-
- Document the rule purpose at the top of the file.
7+
- We particularly welcome contributions to:
8+
- `rules/api-security.yml` (for common API vulnerabilities like auth, CORS, rate limiting)
9+
- `rules/llm-ai-security.yml` (for LLM/AI specific issues like prompt injection, data leakage, insecure output handling)
10+
- `rules/secrets.yml` (for detecting inadvertently committed secrets)
11+
- `rules/code-bugs.yml` (for common coding errors leading to vulnerabilities)
12+
- `rules/prompt-injection.yml` (for general prompt injection patterns)
13+
- Document the rule purpose at the top of the file or within the rule's metadata.
814
- **ZAP:**
915
- Add new config files to `/zap/`.
1016
- Follow ZAP documentation for custom scan policies.

docs/plan/task_6.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
- [x] Script to analyze all scan results (ZAP, Semgrep, Trivy)
44
- [x] Sort and summarize findings by severity
55
- [x] Explicitly output "All OK" sections
6-
- [ ] Generate to-do list for developers
7-
- [ ] Optionally: Generate HTML report
8-
- [ ] Optionally: Slack/Teams/Email notification for critical findings
9-
- [ ] Semgrep rules for API security (Auth, CORS, Rate Limiting)
10-
- [ ] Adjust ZAP policy for API endpoints
11-
- [ ] More Semgrep rules for LLM/AI security
12-
- [ ] Update documentation!
6+
- [x] Generate to-do list for developers
7+
- [x] Optionally: Generate HTML report
8+
- [x] Optionally: Slack/Teams/Email notification for critical findings
9+
- [x] Semgrep rules for API security (Auth, CORS, Rate Limiting)
10+
- [x] Adjust ZAP policy for API endpoints
11+
- [x] More Semgrep rules for LLM/AI security
12+
- [x] Update documentation!

docs/plan/task_7.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Task List: Phase 7 – Advanced Automation, Integration & Developer Experience
22

3-
- [ ] Automatic mapping of all findings to OWASP Top 10, GDPR, NIST, etc.
4-
- [ ] Generate compliance report
5-
- [ ] Plug-in system for new tools/checks
6-
- [ ] Auto-fix suggestions for trivial findings
3+
- [x] Automatic mapping of all findings to OWASP Top 10, GDPR, NIST, etc.
4+
- [x] Generate compliance report
5+
- [x] Plug-in system for new tools/checks
6+
- [x] Auto-fix suggestions for trivial findings
77
- [ ] False-positive handling (whitelist, suppression)
88
- [ ] History/trend analysis of findings
99
- [ ] Dashboard for security status and trends
1010
- [ ] Automatic detection of tech stack and adjustment of checks
1111
- [ ] Ticket creation for critical findings (Jira, GitHub Issues)
1212
- [ ] PDF export of the report
1313
- [ ] Troubleshooting/FAQ and example output in the documentation
14-
- [ ] Video/screen demo for onboarding
14+
- [ ] Video/screen demo for onboarding

rules/api-security.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
rules:
2+
- id: missing-api-authentication
3+
patterns:
4+
- pattern-either:
5+
- pattern-inside: |
6+
@app.route('/api/...')
7+
def $FUNC(...):
8+
...
9+
- pattern-inside: |
10+
@api_view(['GET', 'POST'])
11+
def $FUNC(...):
12+
...
13+
- pattern-not: |
14+
@login_required
15+
...
16+
- pattern-not: |
17+
permission_classes = [IsAuthenticated]
18+
...
19+
- pattern-not-inside: |
20+
if not request.user.is_authenticated:
21+
...
22+
message: >-
23+
API endpoint appears to be missing authentication. Ensure that all API
24+
endpoints handling sensitive data or operations require proper
25+
authentication.
26+
languages:
27+
- python
28+
severity: HIGH
29+
30+
- id: overly-permissive-cors
31+
patterns:
32+
- pattern-either:
33+
- pattern: |
34+
set_header("Access-Control-Allow-Origin", "*")
35+
- pattern: |
36+
CORS(app, resources={r"/api/*": {"origins": "*"}})
37+
- focus-metavariable: $ORIGIN
38+
metavariable-regex:
39+
metavariable: $ORIGIN
40+
regex: \*
41+
message: >-
42+
Overly permissive CORS policy detected (Access-Control-Allow-Origin: *).
43+
This can allow any domain to make requests to your API, potentially
44+
leading to security vulnerabilities. Restrict origins to trusted domains.
45+
languages:
46+
- python
47+
- javascript
48+
- go
49+
severity: MEDIUM
50+
51+
- id: potential-missing-rate-limiting
52+
patterns:
53+
- pattern-inside: |
54+
@app.route('/api/...')
55+
def $FUNC(...):
56+
...
57+
- pattern-not: |
58+
@limiter.limit(...)
59+
...
60+
- pattern-not-inside: |
61+
rate_limit_check(...)
62+
...
63+
message: >-
64+
This API endpoint does not seem to have explicit rate limiting.
65+
Consider adding rate limiting to prevent abuse and ensure availability.
66+
languages:
67+
- python
68+
severity: MEDIUM

rules/llm-ai-security.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
rules:
2+
- id: exposed-llm-api-key
3+
patterns:
4+
- pattern-either:
5+
- pattern: |
6+
OPENAI_API_KEY = "sk-..."
7+
- pattern: |
8+
HF_TOKEN = "hf_..."
9+
- pattern: |
10+
GOOGLE_API_KEY = "AIza..."
11+
- pattern-inside: |
12+
... = os.environ.get("...") # Good: loaded from env
13+
message: "Potential hardcoded LLM API key. Load keys from environment variables or a secure vault."
14+
languages:
15+
- python
16+
severity: CRITICAL
17+
18+
- id: llm-direct-html-output
19+
patterns:
20+
- pattern: |
21+
response = llm.generate(...)
22+
...
23+
return f"<html>{response}</html>"
24+
- pattern-not: |
25+
response = llm.generate(...)
26+
...
27+
safe_response = html.escape(response) # Good: sanitized
28+
return f"<html>{safe_response}</html>"
29+
message: >-
30+
LLM output is directly rendered in HTML without sanitization.
31+
This could lead to XSS if the LLM generates malicious HTML/JavaScript.
32+
Always sanitize LLM outputs before rendering them in web contexts.
33+
languages:
34+
- python
35+
severity: HIGH
36+
37+
- id: llm-prompt-concatenation-user-input
38+
patterns:
39+
- pattern: |
40+
prompt = "Translate to French: " + user_input
41+
llm.generate(prompt)
42+
- pattern: |
43+
prompt = f"Summarize this: {user_text}"
44+
llm.generate(prompt)
45+
message: >-
46+
User input is directly concatenated into an LLM prompt. This is a common
47+
source of prompt injection vulnerabilities. Consider using structured input,
48+
input validation, and output encoding, or specific libraries designed to prevent prompt injection.
49+
languages:
50+
- python
51+
severity: HIGH

0 commit comments

Comments
 (0)