regscale-cli 6.16.1.0__py3-none-any.whl → 6.16.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of regscale-cli might be problematic. Click here for more details.
- regscale/__init__.py +1 -1
- regscale/core/app/internal/login.py +1 -1
- regscale/core/app/internal/poam_editor.py +1 -1
- regscale/core/app/utils/api_handler.py +4 -11
- regscale/integrations/commercial/__init__.py +2 -2
- regscale/integrations/commercial/ad.py +1 -1
- regscale/integrations/commercial/crowdstrike.py +0 -1
- regscale/integrations/commercial/grype/__init__.py +3 -0
- regscale/integrations/commercial/grype/commands.py +72 -0
- regscale/integrations/commercial/grype/scanner.py +390 -0
- regscale/integrations/commercial/import_all/import_all_cmd.py +2 -2
- regscale/integrations/commercial/opentext/__init__.py +6 -0
- regscale/integrations/commercial/opentext/commands.py +77 -0
- regscale/integrations/commercial/opentext/scanner.py +449 -85
- regscale/integrations/commercial/qualys.py +50 -61
- regscale/integrations/commercial/servicenow.py +1 -0
- regscale/integrations/commercial/snyk.py +2 -2
- regscale/integrations/commercial/synqly/ticketing.py +29 -0
- regscale/integrations/commercial/trivy/__init__.py +5 -0
- regscale/integrations/commercial/trivy/commands.py +74 -0
- regscale/integrations/commercial/trivy/scanner.py +276 -0
- regscale/integrations/commercial/veracode.py +1 -1
- regscale/integrations/commercial/wizv2/utils.py +1 -1
- regscale/integrations/jsonl_scanner_integration.py +869 -0
- regscale/integrations/public/fedramp/fedramp_common.py +4 -4
- regscale/integrations/public/fedramp/inventory_items.py +3 -3
- regscale/integrations/scanner_integration.py +225 -59
- regscale/models/integration_models/cisa_kev_data.json +65 -7
- regscale/models/integration_models/{flat_file_importer.py → flat_file_importer/__init__.py} +29 -8
- regscale/models/integration_models/snyk.py +141 -15
- regscale/models/integration_models/synqly_models/capabilities.json +1 -1
- regscale/models/integration_models/tenable_models/integration.py +42 -7
- regscale/models/integration_models/veracode.py +91 -48
- regscale/models/regscale_models/regscale_model.py +1 -1
- regscale/models/regscale_models/user.py +3 -4
- regscale/models/regscale_models/vulnerability.py +21 -0
- regscale/utils/version.py +3 -5
- {regscale_cli-6.16.1.0.dist-info → regscale_cli-6.16.3.0.dist-info}/METADATA +3 -3
- {regscale_cli-6.16.1.0.dist-info → regscale_cli-6.16.3.0.dist-info}/RECORD +43 -38
- regscale/integrations/commercial/grype.py +0 -165
- regscale/integrations/commercial/opentext/click.py +0 -99
- regscale/integrations/commercial/trivy.py +0 -162
- {regscale_cli-6.16.1.0.dist-info → regscale_cli-6.16.3.0.dist-info}/LICENSE +0 -0
- {regscale_cli-6.16.1.0.dist-info → regscale_cli-6.16.3.0.dist-info}/WHEEL +0 -0
- {regscale_cli-6.16.1.0.dist-info → regscale_cli-6.16.3.0.dist-info}/entry_points.txt +0 -0
- {regscale_cli-6.16.1.0.dist-info → regscale_cli-6.16.3.0.dist-info}/top_level.txt +0 -0
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Module for processing Trivy scan results and loading them into RegScale.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
import logging
|
|
6
|
-
import traceback
|
|
7
|
-
from datetime import datetime
|
|
8
|
-
from typing import List, Optional, Union
|
|
9
|
-
|
|
10
|
-
import click
|
|
11
|
-
from pathlib import Path
|
|
12
|
-
|
|
13
|
-
from regscale.core.app.utils.file_utils import (
|
|
14
|
-
download_from_s3,
|
|
15
|
-
find_files,
|
|
16
|
-
iterate_files,
|
|
17
|
-
move_file,
|
|
18
|
-
)
|
|
19
|
-
from regscale.models.integration_models.flat_file_importer import FlatFileImporter
|
|
20
|
-
from regscale.models.integration_models.trivy_import import TrivyImport
|
|
21
|
-
|
|
22
|
-
logger = logging.getLogger(__name__)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class TrivyProcessingError(Exception):
|
|
26
|
-
"""Custom exception for Trivy processing errors."""
|
|
27
|
-
|
|
28
|
-
pass
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
@click.group()
|
|
32
|
-
def trivy():
|
|
33
|
-
"""Performs actions from the Trivy scanner integration."""
|
|
34
|
-
pass
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
@trivy.command("import_scans")
|
|
38
|
-
@FlatFileImporter.common_scanner_options(
|
|
39
|
-
message="File path to the folder containing Trivy .json files to process to RegScale.",
|
|
40
|
-
prompt="File path for Trivy files",
|
|
41
|
-
import_name="trivy",
|
|
42
|
-
)
|
|
43
|
-
@click.option("--destination", "-d", type=click.Path(exists=True, dir_okay=True), required=False)
|
|
44
|
-
@click.option("--file_pattern", "-p", type=str, required=False, default="trivy*.json")
|
|
45
|
-
def import_scans(
|
|
46
|
-
destination: Optional[Path],
|
|
47
|
-
file_pattern: str,
|
|
48
|
-
folder_path: Path,
|
|
49
|
-
regscale_ssp_id: int,
|
|
50
|
-
scan_date: datetime,
|
|
51
|
-
mappings_path: Path,
|
|
52
|
-
disable_mapping: bool,
|
|
53
|
-
s3_bucket: str,
|
|
54
|
-
s3_prefix: str,
|
|
55
|
-
aws_profile: str,
|
|
56
|
-
upload_file: bool,
|
|
57
|
-
) -> None:
|
|
58
|
-
"""
|
|
59
|
-
Process Trivy scan results from a folder containing trivy scan files and load into RegScale.
|
|
60
|
-
"""
|
|
61
|
-
import_trivy_scans(
|
|
62
|
-
destination=destination,
|
|
63
|
-
file_pattern=file_pattern,
|
|
64
|
-
folder_path=folder_path,
|
|
65
|
-
regscale_ssp_id=regscale_ssp_id,
|
|
66
|
-
scan_date=scan_date,
|
|
67
|
-
mappings_path=mappings_path,
|
|
68
|
-
disable_mapping=disable_mapping,
|
|
69
|
-
s3_bucket=s3_bucket,
|
|
70
|
-
s3_prefix=s3_prefix,
|
|
71
|
-
aws_profile=aws_profile,
|
|
72
|
-
upload_file=upload_file,
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def import_trivy_scans(
|
|
77
|
-
folder_path: Path,
|
|
78
|
-
regscale_ssp_id: int,
|
|
79
|
-
scan_date: datetime,
|
|
80
|
-
mappings_path: Optional[Path] = None,
|
|
81
|
-
disable_mapping: Optional[bool] = False,
|
|
82
|
-
s3_bucket: Optional[str] = None,
|
|
83
|
-
s3_prefix: Optional[str] = None,
|
|
84
|
-
aws_profile: Optional[str] = None,
|
|
85
|
-
destination: Optional[Path] = None,
|
|
86
|
-
file_pattern: Optional[str] = "trivy*.json",
|
|
87
|
-
upload_file: Optional[bool] = True,
|
|
88
|
-
) -> None:
|
|
89
|
-
"""
|
|
90
|
-
Process Trivy scan results from a folder container trivy scan files and load into RegScale.
|
|
91
|
-
|
|
92
|
-
:param Path folder_path: Path to the Trivy scan results JSON file
|
|
93
|
-
:param int regscale_ssp_id: RegScale SSP ID
|
|
94
|
-
:param datetime scan_date: The date of the scan
|
|
95
|
-
:param Optional[Path] mappings_path: Path to the header mapping file, default: None
|
|
96
|
-
:param Optional[bool] disable_mapping: Disable the header mapping, default: False
|
|
97
|
-
:param Optional[str] s3_bucket: S3 bucket to download scan files from, default: None
|
|
98
|
-
:param Optional[str] s3_prefix: Prefix (folder path) within the S3 bucket, default: None
|
|
99
|
-
:param Optional[str] aws_profile: AWS profile to use for S3 access, default: None
|
|
100
|
-
:param Optional[Path] destination: The destination folder for the processed files, default: None
|
|
101
|
-
:param Optional[str] file_pattern: The file pattern to search for in the file path Default: trivy*.json
|
|
102
|
-
:param Optional[bool] upload_file: Whether to upload the file to RegScale after processing, default: True
|
|
103
|
-
"""
|
|
104
|
-
from regscale.exceptions import ValidationException
|
|
105
|
-
from regscale.core.app.application import Application
|
|
106
|
-
|
|
107
|
-
try:
|
|
108
|
-
if s3_bucket and s3_prefix and aws_profile:
|
|
109
|
-
download_from_s3(bucket=s3_bucket, prefix=s3_prefix, local_path=destination, aws_profile=aws_profile)
|
|
110
|
-
files = find_files(path=destination, pattern=file_pattern)
|
|
111
|
-
logger.info("Downloaded all Trivy scan files from S3. Processing...")
|
|
112
|
-
elif destination and not s3_bucket:
|
|
113
|
-
logger.info("Moving Trivy scan files to %s", destination)
|
|
114
|
-
stored_file_collection = find_files(path=folder_path, pattern=file_pattern)
|
|
115
|
-
move_all_files(stored_file_collection, destination)
|
|
116
|
-
files = find_files(path=destination, pattern=file_pattern)
|
|
117
|
-
logger.info("Done moving files")
|
|
118
|
-
else:
|
|
119
|
-
stored_file_collection = find_files(path=folder_path, pattern=file_pattern)
|
|
120
|
-
files = stored_file_collection
|
|
121
|
-
if not files:
|
|
122
|
-
logger.error("No Trivy scan results found in the specified directory")
|
|
123
|
-
return
|
|
124
|
-
except Exception as e:
|
|
125
|
-
logger.error(f"Error processing Trivy results: {str(e)}")
|
|
126
|
-
logger.error(traceback.format_exc())
|
|
127
|
-
raise TrivyProcessingError(f"Failed to process Trivy results: {str(e)}")
|
|
128
|
-
|
|
129
|
-
for file in files:
|
|
130
|
-
try:
|
|
131
|
-
TrivyImport(
|
|
132
|
-
name="Trivy",
|
|
133
|
-
app=Application(),
|
|
134
|
-
file_path=str(file),
|
|
135
|
-
file_type=file.suffix,
|
|
136
|
-
parent_id=regscale_ssp_id,
|
|
137
|
-
parent_module="securityplans",
|
|
138
|
-
scan_date=scan_date,
|
|
139
|
-
mappings_path=mappings_path,
|
|
140
|
-
disable_mapping=disable_mapping,
|
|
141
|
-
upload_file=upload_file,
|
|
142
|
-
file_name=file.name,
|
|
143
|
-
)
|
|
144
|
-
except ValidationException as e:
|
|
145
|
-
logger.error(f"Validation error on {file}: {e}")
|
|
146
|
-
continue
|
|
147
|
-
logger.info("Completed Trivy processing.")
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
def move_all_files(file_collection: List[Union[Path, str]], destination: Union[Path, str]) -> None:
|
|
151
|
-
"""
|
|
152
|
-
Move all Trivy files in the current directory to a folder called 'processed'.
|
|
153
|
-
|
|
154
|
-
:param List[Union[Path, str]] file_collection: A list of file paths or S3 URIs
|
|
155
|
-
:param Union[Path, str] destination: The destination folder
|
|
156
|
-
:rtype: None
|
|
157
|
-
"""
|
|
158
|
-
for file in iterate_files(file_collection):
|
|
159
|
-
file_path = Path(file)
|
|
160
|
-
new_filename = f"{file_path.stem}{file_path.suffix}"
|
|
161
|
-
new_file_path = Path(destination) / new_filename
|
|
162
|
-
move_file(file, new_file_path)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|