Skip to content

Commit 7379d3b

Browse files
committed
issues and findings commands
1 parent 7b14921 commit 7379d3b

File tree

17 files changed

+1959
-45
lines changed

17 files changed

+1959
-45
lines changed

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,72 @@ Displays a multi-section dashboard:
9696
- **Open Pull Requests** -- status, issues, coverage, complexity, duplication deltas
9797
- **Issues Overview** -- totals by category, severity, and language
9898

99+
#### `issues <provider> <organization> <repository>`
100+
101+
Search for issues in a repository with optional filters.
102+
103+
```bash
104+
codacy issues gh my-org my-repo
105+
codacy issues gh my-org my-repo --branch main --severities Critical,High
106+
codacy issues gh my-org my-repo --categories Security --overview
107+
codacy issues gh my-org my-repo --output json
108+
```
109+
110+
| Argument | Description |
111+
|---|---|
112+
| `provider` | Git provider: `gh` (GitHub), `gl` (GitLab), or `bb` (Bitbucket) |
113+
| `organization` | Organization name on the provider |
114+
| `repository` | Repository name |
115+
116+
| Option | Description |
117+
|---|---|
118+
| `--branch <branch>` | Branch name (defaults to the main branch) |
119+
| `--patterns <patterns>` | Comma-separated list of pattern IDs |
120+
| `--severities <severities>` | Comma-separated list of severity levels: `Critical`, `High`, `Medium`, `Minor` |
121+
| `--categories <categories>` | Comma-separated list of category names |
122+
| `--languages <languages>` | Comma-separated list of language names |
123+
| `--tags <tags>` | Comma-separated list of tag names |
124+
| `--authors <authors>` | Comma-separated list of author emails |
125+
| `--overview` | Show issue count totals instead of the issues list |
126+
127+
Without `--overview`, displays issues as cards sorted by severity (Error first), with file path, line content, and false-positive warnings where applicable.
128+
129+
With `--overview`, displays issue count totals grouped by: category, severity, language, tag, and author.
130+
131+
#### `findings <provider> <organization> [repository]`
132+
133+
Show security findings for a repository or an entire organization.
134+
135+
```bash
136+
codacy-cloud-cli findings gh my-org my-repo
137+
codacy-cloud-cli findings gh my-org
138+
codacy-cloud-cli findings gh my-org --severities Critical,High
139+
codacy-cloud-cli findings gh my-org my-repo --statuses Overdue,DueSoon
140+
codacy-cloud-cli findings gh my-org my-repo --output json
141+
```
142+
143+
| Argument | Description |
144+
|---|---|
145+
| `provider` | Git provider: `gh` (GitHub), `gl` (GitLab), or `bb` (Bitbucket) |
146+
| `organization` | Organization name on the provider |
147+
| `repository` | Repository name (optional — omit to show org-wide findings) |
148+
149+
| Option | Description |
150+
|---|---|
151+
| `-q, --search <text>` | Search term to filter findings |
152+
| `-s, --severities <severities>` | Comma-separated priority levels: `Critical`, `High`, `Medium`, `Low` |
153+
| `-S, --statuses <statuses>` | Comma-separated statuses: `Overdue`, `OnTrack`, `DueSoon`, `ClosedOnTime`, `ClosedLate`, `Ignored` |
154+
| `-c, --categories <categories>` | Comma-separated security category names |
155+
| `-T, --scan-types <types>` | Comma-separated scan types |
156+
| `-d, --dast-targets <urls>` | Comma-separated DAST target URLs |
157+
158+
Displays findings as cards sorted by priority (Critical first). Each card shows:
159+
- Priority, security category, scan type, and (for pen test findings) likelihood and effort to fix
160+
- Finding title
161+
- Status, due date, CVE/CWE identifiers, affected/fixed versions, application, and affected targets
162+
163+
When browsing org-wide (no repository argument), the repository name is shown on each card.
164+
99165
#### `pull-request <provider> <organization> <repository> <prNumber>`
100166

101167
Show details, analysis status, issues, and changed files for a specific pull request.

TODO.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,64 @@ For the Issues List in particular, showing them in a table will not work. So fol
152152
- [x] 2026-02-18 Write tests for `pull-request` command
153153

154154

155+
### Issues Command
156+
> Search for issues in a repository.
157+
> API Endpoints to use:
158+
- [searchRepositoryIssues](https://api.codacy.com/api/api-docs#searchrepositoryissues)
159+
- [issuesOverview](https://api.codacy.com/api/api-docs#issuesoverview)
160+
161+
Allow these parameters to filter the issues:
162+
- branch: branch name
163+
- patterns: comma separated list of pattern IDs
164+
- severity: comma separated list of severity levels
165+
- category: comma separated list of category names
166+
- language: comma separated list of language names
167+
- tags: comma separated list of tag names
168+
- author: comma separated list of author emails
169+
- overview: boolean to show the overview of the issues instead of the list
170+
171+
Use the same formatting as the `pull-request` command for the issues list.
172+
173+
If `overview` parameter is provided, show the totals by language, category, severity, tag, and author.
174+
175+
Both endpoints accept the same body parameters for filtering (`SearchRepositoryIssuesBody`).
176+
177+
- [x] 2026-02-19 Implement `issues` command - search for issues in a repository
178+
- [x] 2026-02-19 Write tests for `issues` command
179+
180+
181+
### Security Findings Command
182+
> Show security findings for a repository or an organization.
183+
> API Endpoints to use:
184+
- [searchSecurityItems](https://api.codacy.com/api/api-docs#searchsecurityitems)
185+
186+
For this command the repository part is optional.
187+
- codacy findings gh my-org my-repo // list findings for a repository
188+
- codacy findings gh my-org // list findings for the organization
189+
190+
Allow these parameters to filter the findings:
191+
- search: search term to filter the findings
192+
- severities: comma separated list of severity (called priority in the API) names
193+
- statuses: comma separated list of status names
194+
- categories: comma separated list of category names
195+
- scan-types: comma separated list of scan types
196+
- dast-targets: comma separated list of DAST target URLs
197+
198+
Use a similar formatting as the `issues` command, with the same rules (totals, pagination limits, etc.). This is the format:
199+
```
200+
--------------------------------
201+
202+
{Severity/Priority} | {SecurityCategory} {ScanType} | {Optional: Likelihood} {Optional: EffortToFix} | {Optional: Repository Name when seeing organization findings}
203+
{Finding Title}
204+
205+
{Status} {DueAt} | {Optional: CVE or CWE} {Optional: AffectedVersion -> FixedVersion} {Optional: Application} {Optional: AffectedTargets}
206+
207+
--------------------------------
208+
```
209+
210+
- [x] 2026-02-20 Implement `findings` command - show security findings for a repository or an organization
211+
- [x] 2026-02-20 Write tests for `findings` command
212+
155213
## Deployment & CI
156214

157215
- [x] 2026-02-18 Make the project ready to deploy to npm and be executed as a CLI tool by running `npm install -g`
@@ -175,3 +233,5 @@ For the Issues List in particular, showing them in a table will not work. So fol
175233
- 2026-02-18: npm package ready — bin, files, prepublishOnly, tsconfig.build.json, engines
176234
- 2026-02-18: CI pipelines — build+test on push/PR (Node 18/20/22), publish to npm on release
177235
- 2026-02-18: CLI help examples added to all commands
236+
- 2026-02-19: `issues` command implemented with tests (11 tests) — card-style list with filters, `--overview` mode with count tables by category/severity/language/tag/author
237+
- 2026-02-20: `findings` command implemented with tests (13 tests) — card-style list for repo or org-wide, filters by severity/status/category/scan-type/DAST targets, CVE/CWE/version display

package-lock.json

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

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@
3434
"ansis": "4.0.0",
3535
"cli-table3": "^0.6.3",
3636
"commander": "14.0.0",
37-
"dayjs": "^1.11.10",
38-
"ora": "7.0.1"
37+
"date-fns": "4.1.0",
38+
"numeral": "2.0.6",
39+
"ora": "7.0.1",
40+
"pluralize": "8.0.0"
3941
},
4042
"devDependencies": {
4143
"@codacy/openapi-typescript-codegen": "0.0.8",
4244
"@types/commander": "2.12.0",
4345
"@types/node": "22.15.21",
46+
"@types/numeral": "2.0.5",
47+
"@types/pluralize": "0.0.33",
4448
"typescript": "5.8.3",
4549
"vitest": "4.0.18"
4650
}

src/commands/CLAUDE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,30 @@
44

55
Each command is a single file that exports a `register<Name>Command(program: Command)` function. Commands are registered in `src/index.ts`.
66

7+
## Command Aliases
8+
9+
Every command must declare a short alias via `.alias()`. Keep aliases short (2–4 characters) and intuitive:
10+
- `repositories``repos`
11+
- `repository``repo`
12+
- `pull-request``pr`
13+
- `issues``is`
14+
15+
## Option Short Flags
16+
17+
Every command option must have both a short flag and a long flag: `-X, --long-name <value>`. Pick single letters that are intuitive and don't conflict with Commander's built-in flags (`-V/--version`, `-h/--help`) or the global `-o/--output` option. When the natural letter is already taken, use uppercase (e.g. `-O, --overview` instead of `-o`).
18+
19+
## Option Naming: Singular vs Plural
20+
21+
Use a **singular** option name when the parameter accepts a single value, and a **plural** name when it accepts a comma-separated list:
22+
23+
- `--branch main` → singular (one branch)
24+
- `--severities Critical,High` → plural (list of severity levels)
25+
- `--categories Security,CodeStyle` → plural (list of categories)
26+
- `--languages TypeScript,Python` → plural (list of languages)
27+
- `--authors dev@example.com,other@example.com` → plural (list of emails)
28+
29+
This applies to both the long flag name and the metavar: `--severities <severities>`, not `--severities <severity>`.
30+
731
## Output Format
832

933
All commands support `--output json` via the global `-o, --output` option. Commands use `getOutputFormat(this)` (from `utils/output.ts`) to check the format and either:

0 commit comments

Comments
 (0)