globocom / huskyCI

Performing security tests inside your CI
https://huskyci.opensource.globo.com
BSD 3-Clause "New" or "Revised" License
572 stars 137 forks source link

feat: Add SARIF support for easier integration with SAST/SCA tools #564 #566

Closed SimardeepSingh-zsh closed 1 year ago

SimardeepSingh-zsh commented 1 year ago

This Python script is designed to parse SARIF (Static Analysis Results Interchange Format) files. Here’s a step-by-step summary of what the code does:

The parse_sarif function is defined to take a file path as an argument. The function opens the file in read mode and loads the JSON data. It extracts the SARIF version (if available) for reference. It then extracts the ‘runs’ from the data. If no ‘runs’ are found, it returns an empty list. For each ‘run’, it extracts the ‘results’. It initializes an empty list, parsed_results, to store the parsed results. For each ‘result’ in ‘results’, it extracts the ‘ruleId’, ‘message’, and ‘location’ (if available). It appends each extracted result as a dictionary to parsed_results. Finally, it returns a dictionary containing the SARIF version and the parsed results. The example usage at the end of the script demonstrates how to use this function with a SARIF file path, and prints out the parsed data.

This script is useful for projects that need to analyze static analysis results from different tools in a standardized way, as SARIF is a widely adopted standard for representing such results. However, please note that this is a basic implementation and might need to be adapted based on your specific needs and the structure of your SARIF files.

fguisso commented 1 year ago

Hello @SimardeepSingh-zsh thanks for your time. Following #564 the idea is to return a SARIF in Husky's output, today Husky is not an API to summarize findings, then we don't need a script to transform SARIF into another thing.

Since your PR doesn't add new features or fix bugs in our code, I will close it.

If you want some help to contribute more, please reach us in the Community Discussions