@@ -71,7 +71,6 @@ def check(self, scanner: Scanner) -> AuditResult:
7171 self ._check_ip_source (directives ),
7272 self ._check_deprecated_directives (directives ),
7373 self ._check_reporting (directives , response ),
74- self ._check_strict_dynamic (directives ),
7574 self ._check_strict_dynamic_not_standalone (directives ),
7675 self ._check_trusted_types (directives ),
7776 ]
@@ -880,46 +879,6 @@ def _check_reporting(
880879 message = "CSP reporting check completed" ,
881880 )
882881
883- def _check_strict_dynamic (self , directives : dict [str , list [str ]]) -> CheckResult :
884- """Check if allowlist-based CSP should use 'strict-dynamic' (STRICT_CSP severity)."""
885- script_src = directives .get ("script-src" , directives .get ("default-src" , []))
886-
887- # Check if using nonces or hashes
888- has_nonces = any (val .startswith ("'nonce-" ) for val in script_src )
889- has_hashes = any (val .startswith ("'sha" ) for val in script_src )
890-
891- # Check if using allowlists (domains, not keywords)
892- has_allowlist = any (
893- not val .startswith ("'" ) and not val == "https:" and not val == "http:"
894- for val in script_src
895- )
896-
897- # Check if strict-dynamic is present
898- has_strict_dynamic = "'strict-dynamic'" in script_src
899-
900- # If using nonces/hashes with allowlists but no strict-dynamic, recommend it
901- if (has_nonces or has_hashes ) and has_allowlist and not has_strict_dynamic :
902- return CheckResult (
903- name = "strict-dynamic" ,
904- passed = False ,
905- message = "CSP uses nonces/hashes with allowlists (add 'strict-dynamic' to prevent bypasses)" ,
906- )
907-
908- # If using nonces/hashes with strict-dynamic, that's good
909- if (has_nonces or has_hashes ) and has_strict_dynamic :
910- return CheckResult (
911- name = "strict-dynamic" ,
912- passed = True ,
913- message = "CSP uses 'strict-dynamic' with nonces/hashes (modern best practice)" ,
914- )
915-
916- # Otherwise, check not applicable (no nonces/hashes)
917- return CheckResult (
918- name = "strict-dynamic" ,
919- passed = True ,
920- message = "CSP does not use nonces/hashes (strict-dynamic not applicable)" ,
921- )
922-
923882 def _check_strict_dynamic_not_standalone (
924883 self , directives : dict [str , list [str ]]
925884 ) -> CheckResult :
0 commit comments