diff --git a/docs/docset/generate_docset.py b/docs/docset/generate_docset.py index 6f6a6e423..768c20d92 100755 --- a/docs/docset/generate_docset.py +++ b/docs/docset/generate_docset.py @@ -341,13 +341,14 @@ def download(url, docs) -> str: raise ValueError(f'not an http(s) URL: {url}') req = urllib.request.Request(u.geturl(), headers={'User-Agent': USER_AGENT}) # (the scheme is checked above) + # nosemgrep: python.lang.security.audit.dynamic-urllib-use-detected.dynamic-urllib-use-detected with urllib.request.urlopen(req, timeout=20) as r: # nosec B310 data = r.read() ctype = r.headers.get_content_type() path = urllib.parse.unquote(u.path).lstrip('/') ext = os.path.splitext(path)[1] if u.query or not ext or path.endswith('/'): - digest = hashlib.sha1(url.encode(), usedforsecurity=False).hexdigest()[:12] + digest = hashlib.sha256(url.encode()).hexdigest()[:12] path = os.path.join(os.path.dirname(path), digest + CONTENT_TYPE_EXT.get(ctype, ext or '.bin')) rel = os.path.normpath(os.path.join('assets', 'external', u.hostname, path)) out = os.path.join(docs, rel) diff --git a/tools/generate_natvis/generate_natvis.py b/tools/generate_natvis/generate_natvis.py index dc19ec01c..d660c4b63 100755 --- a/tools/generate_natvis/generate_natvis.py +++ b/tools/generate_natvis/generate_natvis.py @@ -139,9 +139,12 @@ if __name__ == '__main__': namespaces += [f'{namespaces[0]}::{ns}' for ns in inline_namespaces] + # The template renders a local XML file, not a web response, and autoescape is enabled. + # nosemgrep: python.flask.security.xss.audit.direct-use-of-jinja2.direct-use-of-jinja2 env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath=sys.path[0]), autoescape=True, trim_blocks=True, lstrip_blocks=True, keep_trailing_newline=True) template = env.get_template('nlohmann_json.natvis.j2') + # nosemgrep: python.flask.security.xss.audit.direct-use-of-jinja2.direct-use-of-jinja2 natvis = template.render(namespaces=namespaces) output = args.output or os.path.join(args.repo_root, 'nlohmann_json.natvis')