Skip to content

Commit 0d9fc5d

Browse files
committed
m
1 parent 18250c3 commit 0d9fc5d

2 files changed

Lines changed: 222 additions & 3 deletions

File tree

‎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/lib/resolveScan.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export async function resolveScan({ repo, scan, branch }) {
3030
const { success, scanHistory, error } = await getScanHistory(repo);
3131
if (!success) throw withExitCode(1, `scan history: ${error}`);
3232

33-
const sorted = [...(scanHistory ?? [])].sort(
34-
(a, b) => new Date(b.timestamp) - new Date(a.timestamp)
35-
);
33+
const sorted = [...(scanHistory ?? [])]
34+
.filter((s) => s.latest_commit_sha && s.timestamp)
35+
.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp));
3636
const filtered = branch ? sorted.filter((s) => s.branch === branch) : sorted;
3737
const pick = filtered[0];
3838

0 commit comments

Comments
 (0)