Compare commits

...

8 Commits

Author SHA1 Message Date
Beverly Nguyen
d3e17c743b Merge pull request #2490 from GSA/sandbox_scan_fix 2025-04-11 09:39:39 -07:00
alexjanousekGSA
e59ddfcae5 Update unit test 2025-04-10 15:58:26 -04:00
alexjanousekGSA
fb11fbfba3 Merged in main 2025-04-10 15:11:28 -04:00
alexjanousekGSA
17a7080f46 Fixing unit tests 2025-04-10 15:10:07 -04:00
alexjanousekGSA
a962da9c7d Added existing csp header 2025-04-10 12:15:34 -04:00
alexjanousekGSA
3a468c77aa Fixed unit test 2025-04-10 08:20:47 -04:00
alexjanousekGSA
fff81870e5 Fixed header 2025-04-08 13:03:01 -04:00
alexjanousekGSA
b5675e586e Fixed security issue and noscript iframe 2025-04-07 14:45:28 -04:00
4 changed files with 30 additions and 172 deletions

View File

@@ -145,6 +145,7 @@ def _csp(config):
"frame-src": [
"https://www.youtube.com",
"https://www.youtube-nocookie.com",
"https://www.googletagmanager.com",
],
"frame-ancestors": "'none'",
"form-action": "'self'",
@@ -169,6 +170,11 @@ def _csp(config):
def create_app(application):
@application.after_request
def add_csp_header(response):
existing_csp = response.headers.get("Content-Security-Policy", "")
response.headers["Content-Security-Policy"] = existing_csp + "; form-action 'self';"
return response
# @application.context_processor
# def inject_feature_flags():
# this is where feature flags can be easily added as a dictionary within context

View File

@@ -14,7 +14,7 @@
<script nonce="{{ csp_nonce() }}">document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');</script>
{% block bodyStart %}
{% block extra_javascripts_before_body %}
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WX5NGWF"
<noscript><iframe sandbox src="https://www.googletagmanager.com/ns.html?id=GTM-WX5NGWF"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
{% endblock %}
{% endblock %}

192
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -14,7 +14,7 @@ def test_owasp_useful_headers_set(
assert response.headers["X-Frame-Options"] == "deny"
assert response.headers["X-Content-Type-Options"] == "nosniff"
csp = response.headers["Content-Security-Policy"]
assert search(r"default-src 'self' static\.example\.com;", csp)
assert search(r"frame-src.*https://www\.googletagmanager\.com", csp)
assert search(r"frame-ancestors 'none';", csp)
assert search(r"form-action 'self';", csp)
assert search(