Skip to content

Commit

Permalink
🐛 fix safety json output
Browse files Browse the repository at this point in the history
  • Loading branch information
MaaniBeigy committed Aug 11, 2024
1 parent 712dc51 commit ebec3eb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Binary file modified .logs/safety.json
Binary file not shown.
29 changes: 26 additions & 3 deletions .shell/safety.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,32 @@ $vulnerabilities_found = $jsonObject.report_meta.vulnerabilities_found
Write-Output $vulnerabilities_found

# Remove the old vulnerabilities.svg file
Remove-Item -Path "assets/images/vulnerabilities.svg" -Force -Recurse
# Remove-Item -Path "assets/images/vulnerabilities.svg" -Force -Recurse

# Define the path to the input and output files
$inputFilePath = ".logs/safety.json"
$outputFilePath = ".logs/safety.json"

# Read the content of the JSON file
$jsonContent = Get-Content -Path $inputFilePath -Raw | ConvertFrom-Json

# Extract the value from the specific path
$vulnerabilitiesFound = $jsonContent.report_meta.vulnerabilities_found

# Create a new object with the desired structure
$result = @{
vulnerabilities_found = $vulnerabilitiesFound
}

# Convert the object to JSON format
$jsonOutput = $result | ConvertTo-Json

# Write the output JSON to a file
$jsonOutput | Set-Content -Path $outputFilePath

Write-Output "The JSON data has been extracted and saved to $outputFilePath"

# Run the Python command using poetry and the extracted value
# Note: Make sure 'poetry' and 'python3' are in your system's PATH
$command = "poetry run python -m pybadges --left-text='vulnerabilities' --right-text='$vulnerabilities_found' --left-color='#40aef9' --right-color='#0c2739' --logo=assets/images/safety.png --embed-logo >> assets/images/vulnerabilities.svg"
Invoke-Expression $command
# $command = "poetry run python -m pybadges --left-text='vulnerabilities' --right-text='$vulnerabilities_found' --left-color='#40aef9' --right-color='#0c2739' --logo=assets/images/safety.png --embed-logo >> assets/images/vulnerabilities.svg"
# Invoke-Expression $command

0 comments on commit ebec3eb

Please sign in to comment.