<reponame>ofirshi/ofirs-smartmove<filename>check.py
import json
import os


# Opening JSON file

def main():
    f_json = open(r'results.json')
    
    # returns JSON object as
    # a dictionary
    data = json.load(f_json)
    # Iterating through the json
    # list
    f_write = open("errors.txt", "w")
    f_write.close()
    f_write = open("errors.txt", "a")
    
    for i in data['code']:
        if i['severity'] == 'CRITICAL' or i['severity'] == 'HIGH':
            print(
                f"severity: {i['severity']} ,file-path: {i['file-path']} , line: {i['line']} ,payload: {i['payload']} ,reason: {i['name']} , remediation: {i['remediation']['message']}")
            f_write.write((
                f"severity: {i['severity']} ,file-path: {i['file-path']} , line: {i['line']} ,payload: {i['payload']} ,reason: {i['name']} , remediation: {i['remediation']['message']}")
            )
    
    # Closing files
    f_json.close()
    f_write.close()


if os.path.exists(r'results.json'):
    main()
