Skip to content

Instantly share code, notes, and snippets.

@h4sh5
Created June 23, 2023 04:28
Show Gist options
  • Save h4sh5/47db0b2eabdad7dac3b506db76d67786 to your computer and use it in GitHub Desktop.
Save h4sh5/47db0b2eabdad7dac3b506db76d67786 to your computer and use it in GitHub Desktop.
check swagger docs for security or the lack thereof
#!/usr/bin/env python3
import yaml
import sys
filename = sys.argv[1]
with open(filename,'r') as f:
d = yaml.safe_load(f)
if 'security' in d:
print('security root level:', d['security'])
print('------')
if 'securityDefinitions' in d:
print('securityDefinitions root level:', d['securityDefinitions'])
print('------')
for path in d['paths']:
for method in d['paths'][path]:
try:
print(method.upper(),path,d['paths'][path][method].get('security'))
except Exception as e:
print("error parsing:",e, method.upper(), path, d['paths'][path][method])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment