Skip to content

Commit c56011a

Browse files
Merge pull request #13 from CodeAnt-AI/scansv2
Scansv2
2 parents d2a8d3b + 03261a1 commit c56011a

48 files changed

Lines changed: 2964 additions & 4 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## [0.4.7] - 22/05/2026
4+
- Scans center
5+
36
## [0.4.6] - 17/04/2026
47
- Secrets false positive
58

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeant-cli",
3-
"version": "0.4.6",
3+
"version": "0.4.7",
44
"description": "Code review CLI tool",
55
"type": "module",
66
"bin": {
@@ -27,7 +27,13 @@
2727
".": "./src/reviewHeadless.js",
2828
"./review": "./src/reviewHeadless.js",
2929
"./push-protection": "./src/utils/installPushProtectionHook.js",
30-
"./config": "./src/utils/config.js"
30+
"./config": "./src/utils/config.js",
31+
"./scans/connection": "./src/scans/connectionHandler.js",
32+
"./scans/list-repos": "./src/scans/listRepos.js",
33+
"./scans/scan-history": "./src/scans/getScanHistory.js",
34+
"./scans/fetch-results": "./src/scans/fetchScanResults.js",
35+
"./scans/fetch-advanced-results": "./src/scans/fetchAdvancedScanResults.js",
36+
"./scans/dismissed-alerts": "./src/scans/fetchDismissedAlerts.js"
3137
},
3238
"files": [
3339
"src"

scans.md

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# `codeant scans`
2+
3+
Fetch and explore scan results from CodeAnt.
4+
5+
```bash
6+
codeant scans <subcommand> [options]
7+
```
8+
9+
---
10+
11+
## Subcommands
12+
13+
### `scans orgs`
14+
15+
List authenticated organizations.
16+
17+
```bash
18+
codeant scans orgs
19+
```
20+
21+
---
22+
23+
### `scans repos`
24+
25+
List repositories for an organization.
26+
27+
```bash
28+
codeant scans repos [options]
29+
```
30+
31+
**Options:**
32+
33+
| Option | Description |
34+
|--------|-------------|
35+
| `--org <org>` | Organization name (auto-picked when only one is authenticated) |
36+
37+
**Examples:**
38+
39+
```bash
40+
# List repos (auto-selects org if only one)
41+
codeant scans repos
42+
43+
# List repos for a specific org
44+
codeant scans repos --org my-org
45+
```
46+
47+
---
48+
49+
### `scans history`
50+
51+
Show scan history for a repository.
52+
53+
```bash
54+
codeant scans history --repo <owner/repo> [options]
55+
```
56+
57+
**Options:**
58+
59+
| Option | Description |
60+
|--------|-------------|
61+
| `--repo <repo>` | **(required)** Repository in `owner/repo` format |
62+
| `--branch <name>` | Filter by branch name |
63+
| `--since <iso>` | Show scans since ISO date (e.g. `2024-01-01`) |
64+
| `--limit <n>` | Max results (default: `20`) |
65+
66+
**Examples:**
67+
68+
```bash
69+
# Show last 20 scans for a repo
70+
codeant scans history --repo acme/backend
71+
72+
# Filter to a specific branch
73+
codeant scans history --repo acme/backend --branch main
74+
75+
# Show scans since a date
76+
codeant scans history --repo acme/backend --since 2024-06-01
77+
78+
# Show up to 50 results
79+
codeant scans history --repo acme/backend --limit 50
80+
```
81+
82+
---
83+
84+
### `scans get`
85+
86+
Show scan metadata and a severity/category summary. Does not include individual findings.
87+
88+
```bash
89+
codeant scans get --repo <owner/repo> [options]
90+
```
91+
92+
**Options:**
93+
94+
| Option | Description |
95+
|--------|-------------|
96+
| `--repo <repo>` | **(required)** Repository in `owner/repo` format |
97+
| `--scan <sha>` | Specific commit SHA to use |
98+
| `--branch <name>` | Resolve latest scan on this branch |
99+
| `--types <list>` | Comma-separated scan types (default: `all`) |
100+
| `--quiet` | Suppress progress output |
101+
102+
**Examples:**
103+
104+
```bash
105+
# Get latest scan summary for a repo
106+
codeant scans get --repo acme/backend
107+
108+
# Get scan for a specific commit
109+
codeant scans get --repo acme/backend --scan abc1234
110+
111+
# Get latest scan on a branch
112+
codeant scans get --repo acme/backend --branch main
113+
114+
# Only include SAST and secrets types
115+
codeant scans get --repo acme/backend --types sast,secrets
116+
117+
# Suppress progress output
118+
codeant scans get --repo acme/backend --quiet
119+
```
120+
121+
---
122+
123+
### `scans results`
124+
125+
Fetch full scan findings for a repository.
126+
127+
```bash
128+
codeant scans results --repo <owner/repo> [options]
129+
```
130+
131+
**Options:**
132+
133+
| Option | Description |
134+
|--------|-------------|
135+
| `--repo <repo>` | **(required)** Repository in `owner/repo` format |
136+
| `--scan <sha>` | Specific commit SHA to use |
137+
| `--branch <name>` | Resolve latest scan on this branch |
138+
| `--types <list>` | Comma-separated types: `sast`, `sca`, `secrets`, `iac`, `dead_code`, `sbom`, `anti_patterns`, `docstring`, `complex_functions`, `all` (default: `all`) |
139+
| `--severity <list>` | Filter by severity (e.g. `critical,high`) |
140+
| `--path <glob>` | Filter by file path glob |
141+
| `--check <regex>` | Filter by check ID or name (regex) |
142+
| `--include-dismissed` | Include dismissed findings (excluded by default) |
143+
| `--format <fmt>` | Output format: `json`, `sarif`, `csv`, `md`, `table` (default: `json`) |
144+
| `--output <path>` | Write output to file instead of stdout |
145+
| `--fields <list>` | Project findings to a subset of fields (comma-separated) |
146+
| `--limit <n>` | Max findings per page (default: `100`) |
147+
| `--offset <n>` | Pagination offset (default: `0`) |
148+
| `--fail-fast` | Exit `3` on first category fetch failure |
149+
| `--no-color` | Disable ANSI color (auto-disabled when not a TTY) |
150+
| `--quiet` | Suppress progress output on stderr |
151+
152+
**Examples:**
153+
154+
```bash
155+
# Fetch all findings (JSON)
156+
codeant scans results --repo acme/backend
157+
158+
# Fetch only critical and high severity findings
159+
codeant scans results --repo acme/backend --severity critical,high
160+
161+
# Fetch SAST findings only
162+
codeant scans results --repo acme/backend --types sast
163+
164+
# Filter to a specific file path
165+
codeant scans results --repo acme/backend --path 'src/**/*.ts'
166+
167+
# Filter by check name using regex
168+
codeant scans results --repo acme/backend --check 'sql-injection'
169+
170+
# Output as a Markdown table
171+
codeant scans results --repo acme/backend --format md
172+
173+
# Output as SARIF to a file
174+
codeant scans results --repo acme/backend --format sarif --output results.sarif
175+
176+
# Include dismissed findings
177+
codeant scans results --repo acme/backend --include-dismissed
178+
179+
# Paginate through results
180+
codeant scans results --repo acme/backend --limit 50 --offset 100
181+
182+
# Project only specific fields
183+
codeant scans results --repo acme/backend --fields id,severity,message,path
184+
```
185+
186+
**Exit codes:**
187+
188+
| Code | Meaning |
189+
|------|---------|
190+
| `0` | Success |
191+
| `1` | General error |
192+
| `3` | Category fetch failure (with `--fail-fast`) |
193+
194+
---
195+
196+
### `scans dismissed`
197+
198+
List dismissed alerts for a repository.
199+
200+
```bash
201+
codeant scans dismissed --repo <owner/repo> [options]
202+
```
203+
204+
**Options:**
205+
206+
| Option | Description |
207+
|--------|-------------|
208+
| `--repo <repo>` | **(required)** Repository in `owner/repo` format |
209+
| `--analysis-type <type>` | Analysis type: `security` or `secrets` (default: `security`) |
210+
211+
**Examples:**
212+
213+
```bash
214+
# List dismissed security alerts
215+
codeant scans dismissed --repo acme/backend
216+
217+
# List dismissed secrets alerts
218+
codeant scans dismissed --repo acme/backend --analysis-type secrets
219+
```

src/commands/scans/dismissed.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { fetchDismissedAlerts } from '../../scans/fetchDismissedAlerts.js';
2+
3+
/**
4+
* codeant scans dismissed --repo <repo> [--analysis-type security|secrets]
5+
*/
6+
export async function runDismissed({ repo, analysisType = 'security' } = {}) {
7+
if (!repo) {
8+
const err = new Error('--repo is required');
9+
err.exitCode = 1;
10+
throw err;
11+
}
12+
13+
const result = await fetchDismissedAlerts(repo, analysisType);
14+
if (!result.success) {
15+
const err = new Error(result.error || 'Failed to fetch dismissed alerts');
16+
err.exitCode = 1;
17+
throw err;
18+
}
19+
20+
return {
21+
repo,
22+
analysis_type: analysisType,
23+
total: result.dismissedAlerts.length,
24+
dismissed_alerts: result.dismissedAlerts,
25+
};
26+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const HEADERS = ['id', 'category', 'severity', 'file_path', 'line_number', 'check_id', 'check_name', 'message', 'cwe', 'cve', 'dismissed'];
2+
3+
function csvCell(val) {
4+
if (val === null || val === undefined) return '';
5+
const s = String(val);
6+
if (s.includes(',') || s.includes('"') || s.includes('\n')) {
7+
return '"' + s.replace(/"/g, '""') + '"';
8+
}
9+
return s;
10+
}
11+
12+
export default {
13+
name: 'csv',
14+
mime: 'text/csv',
15+
extension: '.csv',
16+
render(envelope) {
17+
const { findings = [] } = envelope;
18+
const rows = [HEADERS.join(',')];
19+
for (const f of findings) {
20+
rows.push(HEADERS.map((h) => csvCell(f[h])).join(','));
21+
}
22+
return rows.join('\n');
23+
},
24+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Formatter registry.
3+
* Contract: { name, mime, extension, render(envelope) → string }
4+
* Add a new format = drop a file in formatters/ + one line here.
5+
*/
6+
import json from './json.js';
7+
import sarif from './sarif.js';
8+
import csv from './csv.js';
9+
import md from './md.js';
10+
import table from './table.js';
11+
12+
export const FORMATTERS = { json, sarif, csv, md, table };
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
name: 'json',
3+
mime: 'application/json',
4+
extension: '.json',
5+
render(envelope) {
6+
return JSON.stringify(envelope, null, 2);
7+
},
8+
};

0 commit comments

Comments
 (0)