Skip to content

Commit 0220f14

Browse files
author
drighetto
committed
Fix error - Work on #210
1 parent 18e7dff commit 0220f14

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ci/tab_stats_generate_md_file.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010
import sqlite3
1111
import re
12-
import requests
12+
import json
1313
import hashlib
1414
from collections import Counter
1515
from datetime import datetime
@@ -19,7 +19,7 @@
1919
DEBUG = True
2020
HTTP_REQUEST_TIMEOUT = 60
2121
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"
2323
OSHP_SECURITY_HEADERS_EXTRA_FILE_LOCATION = "/tmp/oshp_headers_extra_to_include.txt"
2424
MD_FILE = "../tab_statistics.md"
2525
IMAGE_FOLDER_LOCATION = "../assets/tab_stats_generated_images"
@@ -72,11 +72,11 @@ def prepare_generation_of_image_from_mermaid(mermaid_code, filename):
7272
def load_oshp_headers():
7373
trace("Call load_oshp_headers()")
7474
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:
8080
header_names.append(http_header["name"].lower())
8181
trace(f"Call load_oshp_headers() :: Load file {OSHP_SECURITY_HEADERS_EXTRA_FILE_LOCATION}")
8282
with open(OSHP_SECURITY_HEADERS_EXTRA_FILE_LOCATION, mode="r", encoding="utf-8") as f:

0 commit comments

Comments
 (0)