vulnhawk 0.1.0__tar.gz
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.
- vulnhawk-0.1.0/.github/workflows/vulnhawk.yml +26 -0
- vulnhawk-0.1.0/.gitignore +13 -0
- vulnhawk-0.1.0/CONTRIBUTING.md +53 -0
- vulnhawk-0.1.0/LICENSE +21 -0
- vulnhawk-0.1.0/PKG-INFO +259 -0
- vulnhawk-0.1.0/README.md +221 -0
- vulnhawk-0.1.0/action/action.yml +114 -0
- vulnhawk-0.1.0/pyproject.toml +76 -0
- vulnhawk-0.1.0/tests/__init__.py +0 -0
- vulnhawk-0.1.0/tests/fixtures/vulnerable_go.go +87 -0
- vulnhawk-0.1.0/tests/fixtures/vulnerable_js.js +120 -0
- vulnhawk-0.1.0/tests/fixtures/vulnerable_python.py +130 -0
- vulnhawk-0.1.0/tests/test_chunker.py +94 -0
- vulnhawk-0.1.0/tests/test_models.py +82 -0
- vulnhawk-0.1.0/tests/test_reporters.py +96 -0
- vulnhawk-0.1.0/vulnhawk/__init__.py +3 -0
- vulnhawk-0.1.0/vulnhawk/cli.py +203 -0
- vulnhawk-0.1.0/vulnhawk/llm/__init__.py +0 -0
- vulnhawk-0.1.0/vulnhawk/llm/base.py +32 -0
- vulnhawk-0.1.0/vulnhawk/llm/claude.py +36 -0
- vulnhawk-0.1.0/vulnhawk/llm/ollama.py +45 -0
- vulnhawk-0.1.0/vulnhawk/llm/openai_backend.py +39 -0
- vulnhawk-0.1.0/vulnhawk/models.py +151 -0
- vulnhawk-0.1.0/vulnhawk/reporters/__init__.py +0 -0
- vulnhawk-0.1.0/vulnhawk/reporters/json_reporter.py +42 -0
- vulnhawk-0.1.0/vulnhawk/reporters/markdown.py +61 -0
- vulnhawk-0.1.0/vulnhawk/reporters/sarif.py +104 -0
- vulnhawk-0.1.0/vulnhawk/reporters/terminal.py +120 -0
- vulnhawk-0.1.0/vulnhawk/rules/__init__.py +0 -0
- vulnhawk-0.1.0/vulnhawk/rules/prompts.py +125 -0
- vulnhawk-0.1.0/vulnhawk/scanner/__init__.py +0 -0
- vulnhawk-0.1.0/vulnhawk/scanner/chunker.py +378 -0
- vulnhawk-0.1.0/vulnhawk/scanner/engine.py +236 -0
- vulnhawk-0.1.0/vulnhawk/scanner/languages/__init__.py +0 -0
- vulnhawk-0.1.0/vulnhawk/utils/__init__.py +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Example workflow: Run VulnHawk on every pull request
|
|
2
|
+
name: VulnHawk Security Scan
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
pull_request:
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
security-events: write # Required for SARIF upload
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
security-scan:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Run VulnHawk
|
|
19
|
+
uses: momenbasel/vulnhawk@main
|
|
20
|
+
with:
|
|
21
|
+
target: '.'
|
|
22
|
+
backend: 'claude'
|
|
23
|
+
mode: 'full'
|
|
24
|
+
severity: 'medium'
|
|
25
|
+
api-key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
26
|
+
fail-on-findings: 'true'
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Contributing to VulnHawk
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/momenbasel/vulnhawk.git
|
|
9
|
+
cd vulnhawk
|
|
10
|
+
uv venv .venv && source .venv/bin/activate
|
|
11
|
+
uv pip install -e ".[dev]"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Running Tests
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pytest
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Code Style
|
|
21
|
+
|
|
22
|
+
We use `ruff` for linting:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
ruff check .
|
|
26
|
+
ruff format .
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Adding Language Support
|
|
30
|
+
|
|
31
|
+
1. Create a new file in `vulnhawk/scanner/languages/`
|
|
32
|
+
2. Add the extension mapping in `vulnhawk/models.py` (`Language.from_extension`)
|
|
33
|
+
3. Add the splitter function in `vulnhawk/scanner/chunker.py`
|
|
34
|
+
4. Add test fixtures in `tests/fixtures/`
|
|
35
|
+
5. Add tests in `tests/test_chunker.py`
|
|
36
|
+
|
|
37
|
+
## Adding a New LLM Backend
|
|
38
|
+
|
|
39
|
+
1. Create a new file in `vulnhawk/llm/`
|
|
40
|
+
2. Implement the `BaseLLM` interface
|
|
41
|
+
3. Add the backend choice in `vulnhawk/cli.py`
|
|
42
|
+
4. Document any required environment variables
|
|
43
|
+
|
|
44
|
+
## Reporting Security Issues
|
|
45
|
+
|
|
46
|
+
If you find a security vulnerability in VulnHawk itself, please report it privately via GitHub Security Advisories rather than opening a public issue.
|
|
47
|
+
|
|
48
|
+
## Pull Requests
|
|
49
|
+
|
|
50
|
+
- Keep PRs focused on a single change
|
|
51
|
+
- Add tests for new functionality
|
|
52
|
+
- Update documentation if needed
|
|
53
|
+
- Run `ruff check .` before submitting
|
vulnhawk-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Moamen Basel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
vulnhawk-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vulnhawk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AI-powered code security scanner that finds vulnerabilities Semgrep and CodeQL miss
|
|
5
|
+
Project-URL: Homepage, https://github.com/momenbasel/vulnhawk
|
|
6
|
+
Project-URL: Repository, https://github.com/momenbasel/vulnhawk
|
|
7
|
+
Project-URL: Issues, https://github.com/momenbasel/vulnhawk/issues
|
|
8
|
+
Author: Moamen Basel
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,appsec,code-analysis,llm,sast,scanner,security,vulnerability
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
23
|
+
Classifier: Topic :: Software Development :: Testing
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: anthropic>=0.40.0
|
|
26
|
+
Requires-Dist: click>=8.0
|
|
27
|
+
Requires-Dist: httpx>=0.27.0
|
|
28
|
+
Requires-Dist: openai>=1.0
|
|
29
|
+
Requires-Dist: pathspec>=0.12.0
|
|
30
|
+
Requires-Dist: pyyaml>=6.0
|
|
31
|
+
Requires-Dist: rich>=13.0
|
|
32
|
+
Requires-Dist: tiktoken>=0.7.0
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.5.0; extra == 'dev'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<img src="https://img.shields.io/pypi/v/vulnhawk?color=blue&label=PyPI" alt="PyPI">
|
|
41
|
+
<img src="https://img.shields.io/pypi/pyversions/vulnhawk" alt="Python">
|
|
42
|
+
<img src="https://img.shields.io/github/license/momenbasel/vulnhawk" alt="License">
|
|
43
|
+
<img src="https://img.shields.io/github/stars/momenbasel/vulnhawk?style=social" alt="Stars">
|
|
44
|
+
</p>
|
|
45
|
+
|
|
46
|
+
<h1 align="center">VulnHawk</h1>
|
|
47
|
+
|
|
48
|
+
<p align="center">
|
|
49
|
+
<strong>AI-powered code security scanner that finds vulnerabilities<br>Semgrep and CodeQL miss.</strong>
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
<p align="center">
|
|
53
|
+
VulnHawk uses AI to understand your code's <em>business logic</em> - not just pattern matching.<br>
|
|
54
|
+
It spots missing auth checks, IDOR flaws, and logic bugs that rule-based tools can't detect.
|
|
55
|
+
</p>
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## What Makes VulnHawk Different
|
|
60
|
+
|
|
61
|
+
Traditional scanners (Semgrep, CodeQL, Bandit) use pattern matching and AST rules. They're great at finding known patterns, but they **can't understand intent**.
|
|
62
|
+
|
|
63
|
+
VulnHawk analyzes your code with AI and cross-references how different parts of your codebase handle security. If 12 endpoints check authorization but one doesn't, VulnHawk catches it.
|
|
64
|
+
|
|
65
|
+
| Feature | Semgrep / CodeQL | VulnHawk |
|
|
66
|
+
|---------|-----------------|----------|
|
|
67
|
+
| Detection method | AST pattern matching | AI code understanding |
|
|
68
|
+
| Business logic bugs | Cannot detect | Detects missing auth, IDOR, logic flaws |
|
|
69
|
+
| Cross-file analysis | Requires custom rules | Automatic - compares similar code patterns |
|
|
70
|
+
| Setup | Write rules, configure | Zero config - works immediately |
|
|
71
|
+
| Finding descriptions | Rule IDs and templates | Natural language with attack scenarios |
|
|
72
|
+
| Fix suggestions | Generic recommendations | Context-specific code fixes |
|
|
73
|
+
|
|
74
|
+
## Quick Start
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install vulnhawk
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Set your LLM API key:
|
|
81
|
+
```bash
|
|
82
|
+
export ANTHROPIC_API_KEY=sk-ant-... # Claude (default)
|
|
83
|
+
# or
|
|
84
|
+
export OPENAI_API_KEY=sk-... # OpenAI
|
|
85
|
+
# or just run Ollama locally # Free, no API key needed
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Scan your code:
|
|
89
|
+
```bash
|
|
90
|
+
vulnhawk scan ./src
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
That's it. No config files, no rule writing, no setup.
|
|
94
|
+
|
|
95
|
+
## Usage
|
|
96
|
+
|
|
97
|
+
### Basic scan
|
|
98
|
+
```bash
|
|
99
|
+
vulnhawk scan ./src
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Focused scanning
|
|
103
|
+
```bash
|
|
104
|
+
# Only check authentication and authorization
|
|
105
|
+
vulnhawk scan ./src --mode auth
|
|
106
|
+
|
|
107
|
+
# Only check for injection vulnerabilities
|
|
108
|
+
vulnhawk scan ./api --mode injection
|
|
109
|
+
|
|
110
|
+
# Only look for hardcoded secrets
|
|
111
|
+
vulnhawk scan . --mode secrets
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Output formats
|
|
115
|
+
```bash
|
|
116
|
+
# JSON output
|
|
117
|
+
vulnhawk scan ./src -o json -f results.json
|
|
118
|
+
|
|
119
|
+
# SARIF for GitHub Code Scanning
|
|
120
|
+
vulnhawk scan ./src -o sarif -f results.sarif
|
|
121
|
+
|
|
122
|
+
# Markdown report
|
|
123
|
+
vulnhawk scan ./src -o markdown -f report.md
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Different LLM backends
|
|
127
|
+
```bash
|
|
128
|
+
# Claude (default, best results)
|
|
129
|
+
vulnhawk scan ./src -b claude
|
|
130
|
+
|
|
131
|
+
# OpenAI
|
|
132
|
+
vulnhawk scan ./src -b openai -m gpt-4o
|
|
133
|
+
|
|
134
|
+
# Ollama (free, local, private)
|
|
135
|
+
vulnhawk scan ./src -b ollama -m llama3.1
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Filter by severity
|
|
139
|
+
```bash
|
|
140
|
+
# Only critical and high
|
|
141
|
+
vulnhawk scan ./src --severity high
|
|
142
|
+
|
|
143
|
+
# Everything including info
|
|
144
|
+
vulnhawk scan ./src --severity info
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Preview what will be scanned
|
|
148
|
+
```bash
|
|
149
|
+
vulnhawk info ./src
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## GitHub Action
|
|
153
|
+
|
|
154
|
+
Add VulnHawk to your CI/CD pipeline:
|
|
155
|
+
|
|
156
|
+
```yaml
|
|
157
|
+
name: Security Scan
|
|
158
|
+
on: [pull_request]
|
|
159
|
+
|
|
160
|
+
permissions:
|
|
161
|
+
security-events: write
|
|
162
|
+
|
|
163
|
+
jobs:
|
|
164
|
+
vulnhawk:
|
|
165
|
+
runs-on: ubuntu-latest
|
|
166
|
+
steps:
|
|
167
|
+
- uses: actions/checkout@v4
|
|
168
|
+
- uses: momenbasel/vulnhawk@main
|
|
169
|
+
with:
|
|
170
|
+
target: '.'
|
|
171
|
+
api-key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
172
|
+
severity: 'medium'
|
|
173
|
+
fail-on-findings: 'true'
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Results automatically appear in GitHub's **Security** tab via SARIF upload.
|
|
177
|
+
|
|
178
|
+
## Scan Modes
|
|
179
|
+
|
|
180
|
+
| Mode | What it checks |
|
|
181
|
+
|------|---------------|
|
|
182
|
+
| `full` | Everything (default) |
|
|
183
|
+
| `auth` | Authentication bypass, missing auth checks, session flaws, JWT issues |
|
|
184
|
+
| `injection` | SQLi, command injection, SSTI, NoSQL injection, XSS |
|
|
185
|
+
| `secrets` | Hardcoded API keys, passwords, tokens, connection strings |
|
|
186
|
+
| `config` | Debug mode, verbose errors, permissive CORS, insecure cookies |
|
|
187
|
+
| `crypto` | Weak hashing, hardcoded keys, insecure random, deprecated algorithms |
|
|
188
|
+
|
|
189
|
+
## Supported Languages
|
|
190
|
+
|
|
191
|
+
- Python
|
|
192
|
+
- JavaScript / TypeScript
|
|
193
|
+
- Go
|
|
194
|
+
- More coming soon (Java, Ruby, PHP, Rust)
|
|
195
|
+
|
|
196
|
+
## How It Works
|
|
197
|
+
|
|
198
|
+
1. **Discover** - Walks your codebase, respects `.gitignore` and `.vulnhawkignore`
|
|
199
|
+
2. **Chunk** - Splits code into logical pieces (functions, classes, routes) with surrounding context
|
|
200
|
+
3. **Enrich** - For each chunk, includes import context and **related code** from elsewhere in the codebase (this is the key differentiator - it shows the AI how other parts handle auth, validation, etc.)
|
|
201
|
+
4. **Analyze** - Sends enriched chunks to the LLM with security-focused analysis prompts
|
|
202
|
+
5. **Validate** - Cross-references findings, removes duplicates, assigns confidence scores
|
|
203
|
+
6. **Report** - Formats results with code snippets, attack scenarios, and fix suggestions
|
|
204
|
+
|
|
205
|
+
The **enrichment step** is what makes VulnHawk fundamentally different. By showing the AI how similar endpoints in your codebase handle security, it can spot the one that doesn't.
|
|
206
|
+
|
|
207
|
+
## Configuration
|
|
208
|
+
|
|
209
|
+
### .vulnhawkignore
|
|
210
|
+
|
|
211
|
+
Create a `.vulnhawkignore` file to exclude paths (same syntax as `.gitignore`):
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
# Skip generated code
|
|
215
|
+
generated/
|
|
216
|
+
*.gen.go
|
|
217
|
+
|
|
218
|
+
# Skip vendor dependencies
|
|
219
|
+
vendor/
|
|
220
|
+
third_party/
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Environment Variables
|
|
224
|
+
|
|
225
|
+
| Variable | Description |
|
|
226
|
+
|----------|-------------|
|
|
227
|
+
| `ANTHROPIC_API_KEY` | API key for Claude backend |
|
|
228
|
+
| `OPENAI_API_KEY` | API key for OpenAI backend |
|
|
229
|
+
|
|
230
|
+
## FAQ
|
|
231
|
+
|
|
232
|
+
**How much does it cost to run?**
|
|
233
|
+
Depends on codebase size and LLM backend. A typical scan of a medium project (~100 files) costs about $0.50-$2.00 with Claude. Use Ollama for free local scanning.
|
|
234
|
+
|
|
235
|
+
**Will it find everything?**
|
|
236
|
+
No security tool catches everything. VulnHawk is best at finding business logic bugs, missing authorization, and context-dependent vulnerabilities that pattern-matching tools miss. Use it alongside (not instead of) Semgrep/CodeQL.
|
|
237
|
+
|
|
238
|
+
**Is my code sent to an external API?**
|
|
239
|
+
Yes, code chunks are sent to the configured LLM provider (Anthropic, OpenAI). Use the Ollama backend for fully local, private scanning.
|
|
240
|
+
|
|
241
|
+
**Does it support monorepos?**
|
|
242
|
+
Yes. Point it at any directory and it will scan all supported files recursively.
|
|
243
|
+
|
|
244
|
+
## Contributing
|
|
245
|
+
|
|
246
|
+
Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
# Development setup
|
|
250
|
+
git clone https://github.com/momenbasel/vulnhawk.git
|
|
251
|
+
cd vulnhawk
|
|
252
|
+
uv venv .venv && source .venv/bin/activate
|
|
253
|
+
uv pip install -e ".[dev]"
|
|
254
|
+
pytest
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
MIT - see [LICENSE](LICENSE)
|
vulnhawk-0.1.0/README.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://img.shields.io/pypi/v/vulnhawk?color=blue&label=PyPI" alt="PyPI">
|
|
3
|
+
<img src="https://img.shields.io/pypi/pyversions/vulnhawk" alt="Python">
|
|
4
|
+
<img src="https://img.shields.io/github/license/momenbasel/vulnhawk" alt="License">
|
|
5
|
+
<img src="https://img.shields.io/github/stars/momenbasel/vulnhawk?style=social" alt="Stars">
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<h1 align="center">VulnHawk</h1>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<strong>AI-powered code security scanner that finds vulnerabilities<br>Semgrep and CodeQL miss.</strong>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
VulnHawk uses AI to understand your code's <em>business logic</em> - not just pattern matching.<br>
|
|
16
|
+
It spots missing auth checks, IDOR flaws, and logic bugs that rule-based tools can't detect.
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## What Makes VulnHawk Different
|
|
22
|
+
|
|
23
|
+
Traditional scanners (Semgrep, CodeQL, Bandit) use pattern matching and AST rules. They're great at finding known patterns, but they **can't understand intent**.
|
|
24
|
+
|
|
25
|
+
VulnHawk analyzes your code with AI and cross-references how different parts of your codebase handle security. If 12 endpoints check authorization but one doesn't, VulnHawk catches it.
|
|
26
|
+
|
|
27
|
+
| Feature | Semgrep / CodeQL | VulnHawk |
|
|
28
|
+
|---------|-----------------|----------|
|
|
29
|
+
| Detection method | AST pattern matching | AI code understanding |
|
|
30
|
+
| Business logic bugs | Cannot detect | Detects missing auth, IDOR, logic flaws |
|
|
31
|
+
| Cross-file analysis | Requires custom rules | Automatic - compares similar code patterns |
|
|
32
|
+
| Setup | Write rules, configure | Zero config - works immediately |
|
|
33
|
+
| Finding descriptions | Rule IDs and templates | Natural language with attack scenarios |
|
|
34
|
+
| Fix suggestions | Generic recommendations | Context-specific code fixes |
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install vulnhawk
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Set your LLM API key:
|
|
43
|
+
```bash
|
|
44
|
+
export ANTHROPIC_API_KEY=sk-ant-... # Claude (default)
|
|
45
|
+
# or
|
|
46
|
+
export OPENAI_API_KEY=sk-... # OpenAI
|
|
47
|
+
# or just run Ollama locally # Free, no API key needed
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Scan your code:
|
|
51
|
+
```bash
|
|
52
|
+
vulnhawk scan ./src
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
That's it. No config files, no rule writing, no setup.
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
### Basic scan
|
|
60
|
+
```bash
|
|
61
|
+
vulnhawk scan ./src
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Focused scanning
|
|
65
|
+
```bash
|
|
66
|
+
# Only check authentication and authorization
|
|
67
|
+
vulnhawk scan ./src --mode auth
|
|
68
|
+
|
|
69
|
+
# Only check for injection vulnerabilities
|
|
70
|
+
vulnhawk scan ./api --mode injection
|
|
71
|
+
|
|
72
|
+
# Only look for hardcoded secrets
|
|
73
|
+
vulnhawk scan . --mode secrets
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Output formats
|
|
77
|
+
```bash
|
|
78
|
+
# JSON output
|
|
79
|
+
vulnhawk scan ./src -o json -f results.json
|
|
80
|
+
|
|
81
|
+
# SARIF for GitHub Code Scanning
|
|
82
|
+
vulnhawk scan ./src -o sarif -f results.sarif
|
|
83
|
+
|
|
84
|
+
# Markdown report
|
|
85
|
+
vulnhawk scan ./src -o markdown -f report.md
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Different LLM backends
|
|
89
|
+
```bash
|
|
90
|
+
# Claude (default, best results)
|
|
91
|
+
vulnhawk scan ./src -b claude
|
|
92
|
+
|
|
93
|
+
# OpenAI
|
|
94
|
+
vulnhawk scan ./src -b openai -m gpt-4o
|
|
95
|
+
|
|
96
|
+
# Ollama (free, local, private)
|
|
97
|
+
vulnhawk scan ./src -b ollama -m llama3.1
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Filter by severity
|
|
101
|
+
```bash
|
|
102
|
+
# Only critical and high
|
|
103
|
+
vulnhawk scan ./src --severity high
|
|
104
|
+
|
|
105
|
+
# Everything including info
|
|
106
|
+
vulnhawk scan ./src --severity info
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Preview what will be scanned
|
|
110
|
+
```bash
|
|
111
|
+
vulnhawk info ./src
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## GitHub Action
|
|
115
|
+
|
|
116
|
+
Add VulnHawk to your CI/CD pipeline:
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
name: Security Scan
|
|
120
|
+
on: [pull_request]
|
|
121
|
+
|
|
122
|
+
permissions:
|
|
123
|
+
security-events: write
|
|
124
|
+
|
|
125
|
+
jobs:
|
|
126
|
+
vulnhawk:
|
|
127
|
+
runs-on: ubuntu-latest
|
|
128
|
+
steps:
|
|
129
|
+
- uses: actions/checkout@v4
|
|
130
|
+
- uses: momenbasel/vulnhawk@main
|
|
131
|
+
with:
|
|
132
|
+
target: '.'
|
|
133
|
+
api-key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
134
|
+
severity: 'medium'
|
|
135
|
+
fail-on-findings: 'true'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Results automatically appear in GitHub's **Security** tab via SARIF upload.
|
|
139
|
+
|
|
140
|
+
## Scan Modes
|
|
141
|
+
|
|
142
|
+
| Mode | What it checks |
|
|
143
|
+
|------|---------------|
|
|
144
|
+
| `full` | Everything (default) |
|
|
145
|
+
| `auth` | Authentication bypass, missing auth checks, session flaws, JWT issues |
|
|
146
|
+
| `injection` | SQLi, command injection, SSTI, NoSQL injection, XSS |
|
|
147
|
+
| `secrets` | Hardcoded API keys, passwords, tokens, connection strings |
|
|
148
|
+
| `config` | Debug mode, verbose errors, permissive CORS, insecure cookies |
|
|
149
|
+
| `crypto` | Weak hashing, hardcoded keys, insecure random, deprecated algorithms |
|
|
150
|
+
|
|
151
|
+
## Supported Languages
|
|
152
|
+
|
|
153
|
+
- Python
|
|
154
|
+
- JavaScript / TypeScript
|
|
155
|
+
- Go
|
|
156
|
+
- More coming soon (Java, Ruby, PHP, Rust)
|
|
157
|
+
|
|
158
|
+
## How It Works
|
|
159
|
+
|
|
160
|
+
1. **Discover** - Walks your codebase, respects `.gitignore` and `.vulnhawkignore`
|
|
161
|
+
2. **Chunk** - Splits code into logical pieces (functions, classes, routes) with surrounding context
|
|
162
|
+
3. **Enrich** - For each chunk, includes import context and **related code** from elsewhere in the codebase (this is the key differentiator - it shows the AI how other parts handle auth, validation, etc.)
|
|
163
|
+
4. **Analyze** - Sends enriched chunks to the LLM with security-focused analysis prompts
|
|
164
|
+
5. **Validate** - Cross-references findings, removes duplicates, assigns confidence scores
|
|
165
|
+
6. **Report** - Formats results with code snippets, attack scenarios, and fix suggestions
|
|
166
|
+
|
|
167
|
+
The **enrichment step** is what makes VulnHawk fundamentally different. By showing the AI how similar endpoints in your codebase handle security, it can spot the one that doesn't.
|
|
168
|
+
|
|
169
|
+
## Configuration
|
|
170
|
+
|
|
171
|
+
### .vulnhawkignore
|
|
172
|
+
|
|
173
|
+
Create a `.vulnhawkignore` file to exclude paths (same syntax as `.gitignore`):
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
# Skip generated code
|
|
177
|
+
generated/
|
|
178
|
+
*.gen.go
|
|
179
|
+
|
|
180
|
+
# Skip vendor dependencies
|
|
181
|
+
vendor/
|
|
182
|
+
third_party/
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Environment Variables
|
|
186
|
+
|
|
187
|
+
| Variable | Description |
|
|
188
|
+
|----------|-------------|
|
|
189
|
+
| `ANTHROPIC_API_KEY` | API key for Claude backend |
|
|
190
|
+
| `OPENAI_API_KEY` | API key for OpenAI backend |
|
|
191
|
+
|
|
192
|
+
## FAQ
|
|
193
|
+
|
|
194
|
+
**How much does it cost to run?**
|
|
195
|
+
Depends on codebase size and LLM backend. A typical scan of a medium project (~100 files) costs about $0.50-$2.00 with Claude. Use Ollama for free local scanning.
|
|
196
|
+
|
|
197
|
+
**Will it find everything?**
|
|
198
|
+
No security tool catches everything. VulnHawk is best at finding business logic bugs, missing authorization, and context-dependent vulnerabilities that pattern-matching tools miss. Use it alongside (not instead of) Semgrep/CodeQL.
|
|
199
|
+
|
|
200
|
+
**Is my code sent to an external API?**
|
|
201
|
+
Yes, code chunks are sent to the configured LLM provider (Anthropic, OpenAI). Use the Ollama backend for fully local, private scanning.
|
|
202
|
+
|
|
203
|
+
**Does it support monorepos?**
|
|
204
|
+
Yes. Point it at any directory and it will scan all supported files recursively.
|
|
205
|
+
|
|
206
|
+
## Contributing
|
|
207
|
+
|
|
208
|
+
Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# Development setup
|
|
212
|
+
git clone https://github.com/momenbasel/vulnhawk.git
|
|
213
|
+
cd vulnhawk
|
|
214
|
+
uv venv .venv && source .venv/bin/activate
|
|
215
|
+
uv pip install -e ".[dev]"
|
|
216
|
+
pytest
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## License
|
|
220
|
+
|
|
221
|
+
MIT - see [LICENSE](LICENSE)
|