You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Python automation script that reads CVE scan requests from `scan.json`, sends them to a vulnerability service, and saves the results to results folder.
3
+
## Confusion matrix Script
4
+
A Python automation script that reads CVE scan requests from `scan.json`, sends them to a vulnerability-analysis service, and saves the results to results folder.
4
5
5
-
## Features
6
+
## Integration tests Script
7
+
A Python automation script that reads several analysis requests tests entries from `scan-it.json` file, sends them to the vulnerability-analysis service, and match results with test entries' expectations.
8
+
9
+
## Common Features
6
10
7
-
- Reads `scan.json` from a configurable input directory
8
11
- Generates payloads from templates for different languages/ecosystems
9
12
- Sends POST requests to the vulnerability service endpoint
10
13
- Saves results to `{scan_id}_{vuln_id}_{iteration}.json` in a configurable output directory
11
-
- Extracts data from result files and exports to CSV format
12
-
- Analyzes results against expected results and generates confusion matrices
14
+
- Extracts data from result files
13
15
- Archives reports into timestamped tar files
14
16
- Supports command-line arguments and environment variables
15
17
- Comprehensive error handling and logging
16
-
- Google Sheets integration for reading input data and writing analysis results
17
18
- Containerized for use in Tekton CI/CD pipelines
18
19
- Automated Docker image builds via GitHub Actions with push and manual trigger options
19
20
21
+
## Confusion Matrix automation features
22
+
- For Generating Confusion Matrix, it reads `scan.json` from a configurable input directory
23
+
- exports extracted data of analysis results to a file of CSV format.
24
+
- Analyzes results against expected results and generates confusion matrices
25
+
- Google Sheets integration for reading input data and writing analysis results
26
+
## Integration Tests automation features
27
+
- For Running Integration tests, it reads `scan-it.json` from a configurable input directory
28
+
- Supports Running the test cases concurrently with ThreadPool of 3 workers.
29
+
- Integration Test semantic logic to compare the actual results with tests' expectations.
30
+
- Colorful logging based on test case failure or success.
20
31
## Requirements
21
32
22
33
- Python 3.9+
@@ -26,6 +37,7 @@ A Python automation script that reads CVE scan requests from `scan.json`, sends
-`--language`: Filter tests by language (e.g., `c`, `go`, `python`). If not specified, runs all languages (default: `None` or `LANGUAGE` env var)
194
+
-`--strict_mode`: If True, Makes test comparison strict => demands both equality for label and exploitability category. If False, still demands equality for exploitability category,
195
+
but allowing actual label to be part of a small list of closely related labels=>
196
+
(e.g `code_not_present` in [`code_not_reachable`, `code_not_present`]).
197
+
If not specified, assumed to be False by default.'
198
+
199
+
200
+
##### File Structure
201
+
202
+
The script expects:
203
+
-**Input**: `scan-it.json`
204
+
-**Output**: Result JSON files named `{scan_id}_{vuln_id}_{iteration}.json` in the output directory
205
+
-**Config**: Configuration files in `src/config/` directory:
206
+
207
+
-`sboms/*.sbom`: SBOM files referenced in scan configuration, for test entries that requires
1.**Input Generation** (if Google Sheets input mode is enabled):
258
+
1.**Input Generation** (if Google Sheets input mode is enabled, Only performed by confusion matrix automation):
155
259
- Reads test data from Google Sheets tabs (`C_Sheet` and `Go_Sheet`)
156
-
- Writes data to CSV files (`prodsec_expected_results_*.csv`) to synchronize with Google Sheets
260
+
- Writes data to CSV files (`prodsec_expected_results_*.csv`) to synchronize with Google Sheets
157
261
- Generates `scan_generated.json` in the input directory
158
262
159
263
2.**Execution**:
160
-
- Reads scan configuration from `scan.json`(or `scan_generated.json`)
264
+
- Reads scan configuration from `scan.json` or `scan_generated.json` ( or `scan-it.json`)
161
265
- Generates payloads from templates for each test
162
266
- Sends POST requests to the vulnerability service
163
267
- Saves results as `{scan_id}_{vuln_id}_{iteration}.json` files
164
268
165
269
3.**Data Extraction**:
166
270
- Extracts key metrics from successful result JSON files
167
-
- Exports extracted data to `extracted_data.csv`
271
+
- Exports extracted data to `extracted_data.csv`
168
272
169
-
4.**Analysis**:
273
+
4.**Analysis** (Only performed by confusion matrix automation):
170
274
- Compares extracted data against expected results
171
275
- Generates confusion matrices (categorical and binary)
172
276
- Calculates performance metrics (Accuracy, Precision, Recall, F1 Score)
173
277
- Exports analysis reports to console and Excel (`merged_data.csv`)
174
278
- Writes results to Google Sheets (if output mode is enabled)
175
279
176
-
5.**Cleanup**:
177
-
- Archives all result files into timestamped tar files
178
-
- Moves archives to `archive/` subdirectory
179
-
- Deletes original result files from reports directory
280
+
281
+
5.**Matching** (Only performed by Integration tests automation)
282
+
- Matching actual results of tests cases with tests cases expected results
283
+
- Demands an exact match on category ( e.g `Exploitable` ,`Not Exploitable`)
284
+
- More flexible on the label, requires either expected_label=actual_label or actual_label to be in a set of common related labels as defined in the test entry' `allowed_deviation_labels`, for example [`code_not_reachable`,`code_not_present`]
285
+
- Prints red color text for a test entry that was failed, and green color text for a test entry that was succeeded.
286
+
- Show statistics for how many tests were failed, and how many succeeded.
287
+
- If all tests succeeded, ending the script with RC=0, otherwise, returns RC=1.
288
+
6.**Cleanup**:
289
+
- Archives all result files into timestamped tar files
290
+
- Moves archives to `archive/` subdirectory
291
+
- Deletes original result files from reports directory
292
+
293
+
180
294
181
295
## Container Usage
182
296
@@ -195,13 +309,15 @@ docker run --rm \
195
309
196
310
**Note:** The image is automatically built and pushed to Quay.io via GitHub Actions. See the [Automated Build with GitHub Actions](#automated-build-with-github-actions) section for details.
197
311
198
-
## Google Sheets Integration
312
+
## Confusion Matrix automation Integrations
199
313
200
-
The script supports reading input data from Google Sheets and writing analysis results to Google Sheets.
314
+
### Google Sheets Integration
201
315
202
-
### Setup
316
+
The Confusion matrix automation script supports reading input data from Google Sheets and writing analysis results to Google Sheets.
203
317
204
-
#### Creating a Google Service Account and Sharing Your Sheet
318
+
#### Setup
319
+
320
+
##### Creating a Google Service Account and Sharing Your Sheet
205
321
206
322
A Service Account is a special "robot" user that allows your application to access Google Sheets without requiring human authentication. Follow these steps to set it up:
Copy file name to clipboardExpand all lines: src/analysis.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -985,7 +985,7 @@ class NoiseReducerProcessorAnalysis(AnalysisProcessor):
985
985
"""
986
986
in cybersecurity, false positive means it was identified wrongly as vulnerable
987
987
In our use case, we're aiming on reducing noises/maximizing the identification of dataset items which are not really exploitable as much as possible (despite the existence of the vulnerable package version), hence :
0 commit comments