Skip to content

Commit ab72e35

Browse files
author
Nicolas Rebagliati
committed
Merge branch 'tkt_77_add_doc_to_pr' into 'dev'
Add doc to PR Closes #77 See merge request faradaysec/faraday-cli!75
2 parents ab7d954 + 2f9442e commit ab72e35

5 files changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[ADD] Add vuln delete vuln-id
2+

docs/docs/commands.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,26 @@ Vulnerability updated
446446
| `--tag TAG` | Tag to add to the vuln. In case that you want add more than one vuln you can repeat this argument |
447447
| `--confirmed CONFIRMED` | Indicates if the Vulnerability is confirmed: True, False |
448448

449+
### vuln delete
450+
451+
Delete a vulnerability
452+
453+
```
454+
$ faraday-cli vuln delete 46 -w test
455+
Vulnerability deleted
456+
```
457+
458+
*Required Arguments:*
459+
460+
| Syntax | Description |
461+
|:----- |------: |
462+
| `-id/--vulnerability-id` | Vulnerability ID |
463+
464+
*Optional Arguments:*
465+
466+
| Syntax | Description |
467+
|:------------------------|----------------|
468+
| `-w WORKSPACE_NAME` | Workspace name |
449469

450470
## Tools and Reports
451471

faraday_cli/api_client/faraday_api.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ def upload_evidence_to_vuln(
264264
self.faraday_api.headers = original_headers
265265
return response.body
266266

267+
@handle_errors
268+
def delete_vuln(self, workspace_name: str, vuln_id):
269+
response = self.faraday_api.vuln.delete(workspace_name, vuln_id)
270+
return response.body
271+
267272
@handle_errors
268273
def update_vuln(
269274
self, workspace_name: str, vulnerability_id: int, body: str

faraday_cli/api_client/resources.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class VulnResource(Resource):
6363
"patch": {"method": "PATCH", "url": "v3/ws/{}/vulns/{}"},
6464
"list": {"method": "GET", "url": "v3/ws/{}/vulns"},
6565
"filter": {"method": "GET", "url": "v3/ws/{}/vulns/filter"},
66+
"delete": {"method": "DELETE", "url": "v3/ws/{}/vulns/{}"},
6667
}
6768

6869

faraday_cli/shell/modules/vulnerability.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pathlib import Path
66

77
import cmd2
8+
from cmd2 import Fg as COLORS
89
from simple_rest_client.exceptions import NotFoundError
910
from tabulate import tabulate
1011
from faraday_cli.extras.halo.halo import Halo
@@ -279,3 +280,39 @@ def update_vuln(self, args: argparse.Namespace):
279280
self._cmd.poutput("Vulnerability updated")
280281
except RequestError as e:
281282
self._cmd.perror(e.message)
283+
284+
delete_vuln_parser = cmd2.Cmd2ArgumentParser()
285+
delete_vuln_parser.add_argument(
286+
"vuln_id", type=int, help="ID of the vulnerability"
287+
)
288+
delete_vuln_parser.add_argument(
289+
"-w", "--workspace-name", type=str, help="Workspace"
290+
)
291+
292+
@cmd2.as_subcommand_to(
293+
"vuln",
294+
"delete",
295+
delete_vuln_parser,
296+
help="Delete existing vulnerability",
297+
)
298+
def delete_vuln(self, args: argparse.Namespace):
299+
"""Delete Vulnerability"""
300+
301+
if not args.workspace_name:
302+
if active_config.workspace:
303+
workspace_name = active_config.workspace
304+
else:
305+
self._cmd.perror("No active Workspace")
306+
return
307+
else:
308+
workspace_name = args.workspace_name
309+
try:
310+
self._cmd.api_client.delete_vuln(workspace_name, args.vuln_id)
311+
except NotFoundError:
312+
self._cmd.perror("Vuln not found")
313+
except Exception as e:
314+
self._cmd.perror(f"{e}")
315+
else:
316+
self._cmd.poutput(
317+
cmd2.style("Vulnerability deleted", fg=COLORS.GREEN)
318+
)

0 commit comments

Comments
 (0)