Files
prplos/scripts/checksec-format-output.py
Cedric DOURLENT 8eaacac69a build: add support for checksec.sh based mitigation reports
Checksec is a bash script to check the properties of executables (like
PIE, RELRO, Canaries, ASLR, Fortify Source).

Add an optional build feature, which when enabled is going to create a
JSON report about the state of mitigations in the produced binaries.

Upstream-Status: Submitted [https://github.com/openwrt/openwrt/pull/14569]
Signed-off-by: Cedric DOURLENT <cedric.dourlent@softathome.com>
2025-07-31 15:20:37 +00:00

35 lines
870 B
Python
Executable File

#!/usr/bin/env python3
from pathlib import Path
from sys import argv
import json
if len(argv) != 6:
print("Usage: checkseck_format_output.py input build_dir package_name package_version output")
exit(1)
input_path = Path(argv[1])
builddir_path = argv[2]
name = argv[3]
version = argv[4]
output_path = Path(argv[5])
output={}
with open(input_path, "r") as read_file:
output["elflist"]={}
data = json.load(read_file)
del data['dir']
for k in list(data):
new=k.replace(builddir_path, "")
output["elflist"][new]=data.pop(k)
output["elflist"][new]["rpath"]="no"
output["elflist"][new]["filename"] = output["elflist"][new]["filename"].replace(builddir_path, "")
output['package'] = name
output['version'] = version
with open(output_path, "w") as write_file:
json.dump(output, write_file)