Before you begin
- Python 3.12 or later.
- Read access to the selected inputs.
Set up your example
- Save as security-json-risky-settings.py.
- Open a terminal in its folder.
- Run python "security-json-risky-settings.py" --help and prepare the listed input files.
Sample files in this download:
- config.json
Download the ZIP, extract it, and open a terminal inside the extracted folder. The source file is security-json-risky-settings.py.
Run the script
python "security-json-risky-settings.py" "config.json"If your system uses python3 instead of python, use that command for Python examples. Keep paths containing spaces in quotes. Required inputs and optional settings are described in the code and setup steps.
What to expect
{"debug": true} produces a $.debug finding without printing unrelated values.
The complete script
#!/usr/bin/env python3
"""Walk a local JSON configuration and flag selected debug, TLS-verification, and wildcard-origin settings."""
import argparse
import sys
import json
from pathlib import Path
def main():
parser = argparse.ArgumentParser(description='Walk a local JSON configuration and flag selected debug, TLS-verification, and wildcard-origin settings.')
parser.add_argument('config',type=Path)
args = parser.parse_args()
data=json.loads(args.config.read_text(encoding='utf-8'))
def walk(value,path='$'):
if isinstance(value,dict):
for key,item in value.items():
location=path+'.'+str(key);normalized=str(key).lower()
if (normalized in {'debug','debug_mode'} and item is True) or (normalized in {'verify_ssl','verify_tls'} and item is False) or (normalized in {'allow_origin','allow_origins'} and (item=='*' or isinstance(item,list) and '*' in item)):print(json.dumps({'path':location,'issue':'review security-sensitive setting'}))
walk(item,location)
elif isinstance(value,list):
for i,item in enumerate(value):walk(item,f'{path}[{i}]')
walk(data)
if __name__ == '__main__':
try:
main()
except (OSError, ValueError, RuntimeError) as exc:
print(f'Error: {exc}', file=sys.stderr)
sys.exit(1)
Open source as plain text · Download source and sample files
How it works
- Walk a local JSON configuration and flag selected debug, TLS-verification, and wildcard-origin settings.
- Arguments are explicit and expected input errors produce a message with a nonzero exit code.
- Results reflect your selected local data or the specific endpoint you choose; the example illustrates the result shape.
Make it your own
Adapt the task
Edit the normalized-key sets for your application. A development configuration may intentionally enable these values.
Adjust presentation
Edit final print statements or json.dumps indentation to adjust the report layout. Keep input validation and exclusive-create file modes intact.
Change one setting at a time, run it again on sample data, and compare the output. The customization guide walks through this process.
If something goes wrong
An input or dependency is unavailable.
Check the path, quote paths with spaces, and use --help to inspect required arguments.
Actual results differ from the example.
Inputs and system state determine values. Review each finding in context; a report is not proof of system health or a complete security assessment.
Reference & next steps
These official references explain the underlying tools. The Scriptage example and guide are original instructional content. See verification notes for what has been checked and the limits of those checks.
Copies a template for your own notes. It does not send anything.