Skip to content

Commit 55177b9

Browse files
docs: update README for v0.1.2 with V2 agent scanner and diff-aware analysis
1 parent 07d0af3 commit 55177b9

1 file changed

Lines changed: 61 additions & 42 deletions

File tree

README.md

Lines changed: 61 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,69 @@
66

77
# CodeScanAI
88

9-
CodeScanAI utilizes a variety of AI models to scan your codebase for bad development practices. It is currently configured to catch potential security vulnerabilities, but will be extended to other use cases in the future. It leverages powerful LLM models to provide suggestions on ways to improve the security of your codebase from external attacks, unauthorized access, etc. The currently supported AI models include:
9+
CodeScanAI utilizes a variety of AI models to scan your codebase for security vulnerabilities. It leverages powerful LLM models to identify risks and provide actionable remediation suggestions. The currently supported AI providers include:
1010

1111
- OpenAI,
1212
- Google Gemini, and
13-
- custom self-hosted AI servers.
13+
- custom self-hosted AI servers (Ollama, etc.).
1414

15-
It has also been designed to enable seamless integration into CI/CD pipelines like GitHub Actions, or can be used via a simple CLI command locally. The idea behind CodeScanAI is to enable developers automatically detect potential security issues in their code throughout the development process.
15+
It has been designed to integrate seamlessly into CI/CD pipelines like GitHub Actions, or can be used via a simple CLI command locally.
1616

1717
Check out the detailed [demo and setup](https://github.com/codescan-ai/codescanai-demo) and try it out today!
1818

19+
## What's new in v0.1.2
20+
21+
- **Pydantic-AI agent scanner:** Files are now scanned one at a time by a structured AI agent, returning typed `FileScanResult` output instead of a raw markdown string.
22+
- **Inline PR review comments:** When running a PR scan, findings are posted as inline review comments directly on the relevant line in the diff. Falls back to a regular issue comment for architectural findings with no specific line.
23+
- **Diff-aware analysis:** When scanning a PR or local git diff, changed lines are highlighted with a `[CHANGED]` marker in the prompt. The agent prioritises those lines while retaining full file context for accurate data flow analysis.
24+
1925
## Features
2026

2127
- **Flexible Scanning Options:**
22-
- **Full Directory Scans:** You can perform a comprehensive security analysis by scanning all files within a directory.
23-
- **Changes Only Scan:** Supports the ability to scan only those files that have changed since the last scan.
24-
- **PR-Specific Scans:** Only scan the files modified in a specific pull request to optimize the scanning process, reduce overhead and ensure new code changes are up to standard.
28+
- **Full Directory Scans:** Comprehensive security analysis across all files in a directory.
29+
- **Changes Only Scan:** Scan only files changed since the last commit (`--changes_only`).
30+
- **PR-Specific Scans:** Scan only files modified in a specific pull request, with findings posted as inline review comments.
31+
32+
- **Diff-Aware PR Analysis:**
33+
34+
When scanning a pull request, CodeScanAI fetches the exact lines changed in the diff and annotates them for the agent. This focuses the analysis on new and modified code while preserving full file context to avoid false negatives.
2535

2636
- **Support for Multiple AI Models:**
2737

28-
CodeScanAI provides support for a range of AI models. It currently supports OpenAI, Google Gemini, and self hosted model. Based on user demands, we can add support for other popular AI models like Claude, Grok, etc.
38+
Supports OpenAI, Google Gemini, and any self-hosted OpenAI-compatible server. Support for additional providers can be added on demand.
2939

3040
- **CI/CD Integration:**
3141

32-
- Seamlessly integrate the CLI tool into GitHub Actions for automated security vulnerability scanning on every pull request.
33-
- Supports targeted scans on specific branches or changes within a repository.
42+
Integrate into GitHub Actions for automated security scanning on every pull request. Supports targeted scans on specific branches or changes within a repository.
3443

3544
## Getting Started
3645

3746
### Prerequisites
3847

3948
- Python 3.10 or higher
40-
- API keys for the supported AI models:
49+
- API key for your chosen provider:
4150
- OpenAI API key, OR
4251
- Gemini API key, OR
4352
- Access to a custom AI server (host, port, and optional token)
44-
- Set an environment variable for your API key(s).
4553

4654
```bash
47-
export OPENAI_API_KEY = 'your_openai_api_key'
55+
export OPENAI_API_KEY='your_openai_api_key'
4856

49-
export GEMINI_API_KEY = 'your_gemini_api_key'
57+
export GEMINI_API_KEY='your_gemini_api_key'
5058
```
5159

5260
### Installation
5361

5462
#### Option 1: Install via pip
5563

56-
You can install the tool directly from the repository using pip:
57-
5864
```bash
5965
pip install codescanai
6066
```
6167

62-
This will allow you to use the `codescanai` command directly in your terminal.
68+
This will make the `codescanai` command available directly in your terminal.
6369

6470
#### Option 2: Clone the Repository
6571

66-
If you prefer to clone the repository and install the dependencies manually:
67-
6872
```bash
6973
git clone https://github.com/codescan-ai/codescan.git
7074
cd codescan
@@ -73,59 +77,74 @@ pip install -r requirements.txt
7377

7478
### Usage
7579

76-
#### Scanning files in your current directory
80+
#### Scan all files in your current directory
7781

7882
```bash
7983
codescanai --provider openai
8084
```
81-
OR if you're cloning the repository,
85+
86+
Or if you cloned the repository:
87+
8288
```bash
83-
python3 -m core.runner --provider openai
89+
python3 -m core.runner_v2 --provider openai
8490
```
8591

86-
#### Scanning with a Custom AI Server
92+
#### Scan only changed files (local git diff)
8793

88-
To scan code using a custom AI server:
94+
```bash
95+
codescanai --provider openai --changes_only
96+
```
97+
98+
#### Scan a GitHub pull request
99+
100+
```bash
101+
codescanai --provider openai \
102+
--repo owner/repo \
103+
--pr_number 42 \
104+
--github_token your_github_token
105+
```
106+
107+
Findings will be posted as inline review comments on the PR.
108+
109+
#### Scan with a Custom AI Server
89110

90111
```bash
91-
codescanai --provider custom --host <http://localhost> --port <5000> --token <your_token> --directory <path/to/your/code>
112+
codescanai --provider custom --host http://localhost --port 5000 --token your_token --directory path/to/code
92113
```
93114

94115
Using locally running [Ollama](https://github.com/ollama/ollama):
95116

96117
```bash
97-
codescanai --provider custom --model <model_name> --host http://localhost --port 11434 --endpoint /api/generate --directory <path/to/your/code>
118+
codescanai --provider custom --model llama3 --host http://localhost --port 11434 --endpoint /api/generate --directory path/to/code
98119
```
99120

100121
### Supported arguments
101122

102123
| name | description | required | default |
103124
| -------------- | --------------------------------------------------------- | -------- | -------------- |
104-
| `provider` | <p>AI provider</p> | `true` | `""` |
105-
| `model` | <p>AI model to use</p> | `false` | `""` |
106-
| `directory` | <p>Directory to scan</p> | `false` | `.` |
107-
| `changes_only` | <p>Scan only changed files</p> | `false` | `false` |
108-
| `repo` | <p>GitHub repository</p> | `false` | `""` |
109-
| `pr_number` | <p>Pull request number</p> | `false` | `""` |
110-
| `github_token` | <p>GitHub API token</p> | `false` | `""` |
111-
| `host` | <p>Custom AI server host</p> | `false` | `""` |
112-
| `port` | <p>Custom AI server port</p> | `false` | `""` |
113-
| `token` | <p>Token for authenticating with the custom AI server</p> | `false` | `""` |
114-
| `endpoint` | <p>API endpoint for the custom server</p> | `false` | `/api/v1/scan` |
125+
| `provider` | AI provider (`openai`, `gemini`, `custom`) | `true` | `""` |
126+
| `model` | AI model to use | `false` | `""` |
127+
| `directory` | Directory to scan | `false` | `.` |
128+
| `changes_only` | Scan only files changed in the local git repo | `false` | `false` |
129+
| `repo` | GitHub repository (`owner/repo`) | `false` | `""` |
130+
| `pr_number` | Pull request number | `false` | `""` |
131+
| `github_token` | GitHub API token (required for PR scans) | `false` | `""` |
132+
| `host` | Custom AI server host | `false` | `""` |
133+
| `port` | Custom AI server port | `false` | `""` |
134+
| `token` | Token for authenticating with the custom AI server | `false` | `""` |
135+
| `endpoint` | API endpoint for the custom server | `false` | `/api/v1/scan` |
115136

116137
### Limitations
117138

118-
- **Large number of files:** We currently do not support scalable way to scan a large number of files on a single run. Depending on the capacity of your AI Provider, you might run into a `rate_limit_exceeded` error. To do this, you can create a custom solution that breaks down the number of files for each run.
139+
- **Rate limits:** Depending on your AI provider's capacity, scanning a large number of files in a single run may hit rate limits. The V2 scanner processes files one at a time, which helps, but you may still need to break up very large directories manually.
119140

120141
## Future Work
121142

122-
- **Batch Processing:** For the limitation above, a future version will be to implement batch processing for a large number of files.
123-
124-
- **Caching Implementation:** A caching mechanism to store results of previously scanned files, reducing the number of API calls and optimizing performance.
143+
- **Caching:** Store results of previously scanned files to reduce API calls and speed up repeat scans.
125144

126-
- **Expanded Git Provider Support:** The tool is currently integrated with GitHub for PR-based scanning, future plans include extending support to other Git providers like GitLab, Bitbucket, and Azure Repos.
145+
- **Expanded Git Provider Support:** Currently integrated with GitHub. Future plans include GitLab, Bitbucket, and Azure Repos.
127146

128-
- **Expanded Development tools:** This will be a plan to expand this tool to be accessible in other development environments. For example, as a VSCode extension.
147+
- **Expanded Development Tools:** Plans to make CodeScanAI accessible as a VSCode extension and in other development environments.
129148

130149
## Contributing
131150

0 commit comments

Comments
 (0)