|
9 | 9 | """
|
10 | 10 | import sqlite3
|
11 | 11 | import re
|
12 |
| -import requests |
| 12 | +import json |
13 | 13 | import hashlib
|
14 | 14 | from collections import Counter
|
15 | 15 | from datetime import datetime
|
|
19 | 19 | DEBUG = True
|
20 | 20 | HTTP_REQUEST_TIMEOUT = 60
|
21 | 21 | DATA_DB_FILE = "/tmp/data.db"
|
22 |
| -OSHP_SECURITY_HEADERS_FILE_lOCATION = "https://owasp.org/www-project-secure-headers/ci/headers_add.json" |
| 22 | +OSHP_SECURITY_HEADERS_FILE_lOCATION = "headers_add.json" |
23 | 23 | OSHP_SECURITY_HEADERS_EXTRA_FILE_LOCATION = "/tmp/oshp_headers_extra_to_include.txt"
|
24 | 24 | MD_FILE = "../tab_statistics.md"
|
25 | 25 | IMAGE_FOLDER_LOCATION = "../assets/tab_stats_generated_images"
|
@@ -72,11 +72,11 @@ def prepare_generation_of_image_from_mermaid(mermaid_code, filename):
|
72 | 72 | def load_oshp_headers():
|
73 | 73 | trace("Call load_oshp_headers()")
|
74 | 74 | header_names = []
|
75 |
| - trace(f"Call load_oshp_headers() :: HTTP Request to {OSHP_SECURITY_HEADERS_FILE_lOCATION}") |
76 |
| - resp = requests.get(OSHP_SECURITY_HEADERS_FILE_lOCATION, timeout=HTTP_REQUEST_TIMEOUT) |
77 |
| - if resp.status_code != 200: |
78 |
| - raise Exception(f"Status code {resp.status_code} received for {OSHP_SECURITY_HEADERS_FILE_lOCATION}!") |
79 |
| - for http_header in resp.json()["headers"]: |
| 75 | + trace(f"Call load_oshp_headers() :: Load and parse file {OSHP_SECURITY_HEADERS_FILE_lOCATION}") |
| 76 | + with open(OSHP_SECURITY_HEADERS_FILE_lOCATION, mode="r", encoding="utf-8") as f: |
| 77 | + data = json.load(f) |
| 78 | + http_headers = data["headers"] |
| 79 | + for http_header in http_headers: |
80 | 80 | header_names.append(http_header["name"].lower())
|
81 | 81 | trace(f"Call load_oshp_headers() :: Load file {OSHP_SECURITY_HEADERS_EXTRA_FILE_LOCATION}")
|
82 | 82 | with open(OSHP_SECURITY_HEADERS_EXTRA_FILE_LOCATION, mode="r", encoding="utf-8") as f:
|
|
0 commit comments