Skip to content

Commit

Permalink
Filtered duplicates from queried urls in test
Browse files Browse the repository at this point in the history
Fixed incorrectly placed annotation in test

Removed annotation
  • Loading branch information
andrecsilva committed Jan 8, 2025
1 parent 923e14f commit cafe85d
Show file tree
Hide file tree
Showing 28 changed files with 40 additions and 34 deletions.
12 changes: 9 additions & 3 deletions integration_tests/test_codemod_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ async def check_accessible_urls(urls):

@pytest.mark.asyncio
async def test_codemod_reference_urls():
urls = [
ref.url for codemod in registry.codemods for ref in codemod._metadata.references
]
urls = list(
set(
[
ref.url
for codemod in registry.codemods
for ref in codemod._metadata.references
]
)
)
await check_accessible_urls(urls)


Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/add_requests_timeouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def on_result_found(self, original_node, updated_node):
Reference(
url="https://docs.python-requests.org/en/master/user/quickstart/#timeouts"
),
Reference(url="https://cwe.mitre.org/data/definitions/1088.html"),
Reference(url="https://cwe.mitre.org/data/definitions/1088"),
],
),
detector=SemgrepRuleDetector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def leave_Call(
],
),
references=[
Reference(url="https://cwe.mitre.org/data/definitions/502.html"),
Reference(url="https://cwe.mitre.org/data/definitions/502"),
],
),
transformer=LibcstTransformerPipeline(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def leave_Call(self, original_node: cst.Call, updated_node: cst.Call) -> cst.Cal
],
),
references=[
Reference(url="https://cwe.mitre.org/data/definitions/614.html"),
Reference(url="https://cwe.mitre.org/data/definitions/614"),
],
),
transformer=LibcstTransformerPipeline(DjangoSecureSetCookieTransformer),
Expand Down
4 changes: 2 additions & 2 deletions src/core_codemods/disable_graphql_introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ def _is_introspection_rule_or_starred(
url="https://owasp.org/www-project-web-security-testing-guide/v42/4-Web_Application_Security_Testing/12-API_Testing/01-Testing_GraphQL#introspection-queries",
),
Reference(
url="https://cwe.mitre.org/data/definitions/200.html",
url="https://cwe.mitre.org/data/definitions/200",
),
Reference(
url="https://cwe.mitre.org/data/definitions/669.html",
url="https://cwe.mitre.org/data/definitions/669",
),
],
),
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/django_debug_flag_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DjangoDebugFlagOn(SimpleCodemod):
Reference(
url="https://docs.djangoproject.com/en/4.2/ref/settings/#std-setting-DEBUG"
),
Reference(url="https://cwe.mitre.org/data/definitions/489.html"),
Reference(url="https://cwe.mitre.org/data/definitions/489"),
],
)
change_description = "Flip `Django` debug flag to off."
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/django_session_cookie_secure_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DjangoSessionCookieSecureOff(SimpleCodemod):
Reference(
url="https://docs.djangoproject.com/en/4.2/ref/settings/#session-cookie-secure"
),
Reference(url="https://cwe.mitre.org/data/definitions/614.html"),
Reference(url="https://cwe.mitre.org/data/definitions/614"),
],
)
change_description = "Sets Django's `SESSION_COOKIE_SECURE` flag if off or missing."
Expand Down
4 changes: 2 additions & 2 deletions src/core_codemods/file_resource_leak.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def line_filter(x):
summary="Automatically Close Resources",
review_guidance=ReviewGuidance.MERGE_WITHOUT_REVIEW,
references=[
Reference(url="https://cwe.mitre.org/data/definitions/404.html"),
Reference(url="https://cwe.mitre.org/data/definitions/772.html"),
Reference(url="https://cwe.mitre.org/data/definitions/404"),
Reference(url="https://cwe.mitre.org/data/definitions/772"),
],
),
transformer=LibcstTransformerPipeline(FileResourceLeakTransformer),
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/flask_enable_csrf_protection.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FlaskEnableCSRFProtection(
references=[
Reference(url="https://owasp.org/www-community/attacks/csrf"),
Reference(url="https://flask-wtf.readthedocs.io/en/1.2.x/csrf/"),
Reference(url="https://cwe.mitre.org/data/definitions/352.html"),
Reference(url="https://cwe.mitre.org/data/definitions/352"),
],
)

Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/harden_pickle_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HardenPickleLoad(SimpleCodemod, ImportModifierCodemod):
url="https://github.com/trailofbits/fickling",
),
Reference(
url="https://cwe.mitre.org/data/definitions/502.html",
url="https://cwe.mitre.org/data/definitions/502",
),
],
)
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/harden_pyyaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def _update_bases(
Reference(
url="https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation"
),
Reference(url="https://cwe.mitre.org/data/definitions/502.html"),
Reference(url="https://cwe.mitre.org/data/definitions/502"),
],
),
detector=SemgrepRuleDetector(
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/harden_ruamel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HardenRuamel(SimpleCodemod):
Reference(
url="https://owasp.org/www-community/vulnerabilities/Deserialization_of_untrusted_data"
),
Reference(url="https://cwe.mitre.org/data/definitions/502.html"),
Reference(url="https://cwe.mitre.org/data/definitions/502"),
],
)
change_description = (
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/https_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class HTTPSConnection(SimpleCodemod):
Reference(
url="https://urllib3.readthedocs.io/en/stable/reference/urllib3.connectionpool.html#urllib3.HTTPConnectionPool"
),
Reference(url="https://cwe.mitre.org/data/definitions/319.html"),
Reference(url="https://cwe.mitre.org/data/definitions/319"),
],
)

Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/limit_readline.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LimitReadline(SimpleCodemod):
summary="Limit readline()",
review_guidance=ReviewGuidance.MERGE_AFTER_CURSORY_REVIEW,
references=[
Reference(url="https://cwe.mitre.org/data/definitions/400.html"),
Reference(url="https://cwe.mitre.org/data/definitions/400"),
],
)
change_description = "Adds a size limit argument to readline() calls."
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/lxml_safe_parser_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LxmlSafeParserDefaults(SimpleCodemod):
Reference(
url="https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html"
),
Reference(url="https://cwe.mitre.org/data/definitions/611.html"),
Reference(url="https://cwe.mitre.org/data/definitions/611"),
],
)
change_description = "Replace `lxml` parser parameters with safe defaults."
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/lxml_safe_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LxmlSafeParsing(SimpleCodemod):
Reference(
url="https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html"
),
Reference(url="https://cwe.mitre.org/data/definitions/611.html"),
Reference(url="https://cwe.mitre.org/data/definitions/611"),
],
)
change_description = (
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/replace_flask_send_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ReplaceFlaskSendFile(SimpleCodemod, NameAndAncestorResolutionMixin):
url="https://flask.palletsprojects.com/en/3.0.x/api/#flask.send_from_directory"
),
Reference(url="https://owasp.org/www-community/attacks/Path_Traversal"),
Reference(url="https://cwe.mitre.org/data/definitions/35.html"),
Reference(url="https://cwe.mitre.org/data/definitions/35"),
],
)

Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/requests_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RequestsVerify(SimpleCodemod):
Reference(
url="https://owasp.org/www-community/attacks/Manipulator-in-the-middle_attack"
),
Reference(url="https://cwe.mitre.org/data/definitions/295.html"),
Reference(url="https://cwe.mitre.org/data/definitions/295"),
],
)
change_description = (
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/secure_flask_cookie.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SecureFlaskCookie(SimpleCodemod, SecureCookieMixin):
Reference(
url="https://owasp.org/www-community/controls/SecureCookieAttribute"
),
Reference(url="https://cwe.mitre.org/data/definitions/614.html"),
Reference(url="https://cwe.mitre.org/data/definitions/614"),
],
)
change_description = "Flask response `set_cookie` call should be called with `secure=True`, `httponly=True`, and `samesite='Lax'`."
Expand Down
6 changes: 3 additions & 3 deletions src/core_codemods/secure_flask_session_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class SecureFlaskSessionConfig(SimpleCodemod, Codemod):
Reference(
url="https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html"
),
Reference(url="https://cwe.mitre.org/data/definitions/319.html"),
Reference(url="https://cwe.mitre.org/data/definitions/352.html"),
Reference(url="https://cwe.mitre.org/data/definitions/614.html"),
Reference(url="https://cwe.mitre.org/data/definitions/319"),
Reference(url="https://cwe.mitre.org/data/definitions/352"),
Reference(url="https://cwe.mitre.org/data/definitions/614"),
],
)
change_description = "Flip Flask session configuration if defined as insecure."
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/semgrep/semgrep_nan_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def visit_Call(self, node: cst.Call) -> None:
],
),
references=[
Reference(url="https://cwe.mitre.org/data/definitions/704.html"),
Reference(url="https://cwe.mitre.org/data/definitions/704"),
],
),
transformer=LibcstTransformerPipeline(NanInjectionTransformer),
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/semgrep/semgrep_no_csrf_exempt.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def leave_Decorator(
],
),
references=[
Reference(url="https://cwe.mitre.org/data/definitions/352.html"),
Reference(url="https://cwe.mitre.org/data/definitions/352"),
],
),
transformer=LibcstTransformerPipeline(RemoveCsrfExemptTransformer),
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/semgrep/semgrep_rsa_key_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def match_location(self, pos, result):
],
),
references=[
Reference(url="https://cwe.mitre.org/data/definitions/326.html"),
Reference(url="https://cwe.mitre.org/data/definitions/326"),
],
),
transformer=LibcstTransformerPipeline(RsaKeySizeTransformer),
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/sql_parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def _remove_literal_and_gather_extra(
review_guidance=ReviewGuidance.MERGE_AFTER_CURSORY_REVIEW,
references=[
Reference(url="https://cwe.mitre.org/data/definitions/20"),
Reference(url="https://cwe.mitre.org/data/definitions/89.html"),
Reference(url="https://cwe.mitre.org/data/definitions/89"),
Reference(url="https://owasp.org/www-community/attacks/SQL_Injection"),
],
),
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/subprocess_shell_false.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def first_arg_is_not_string(self, original_node: cst.Call) -> bool:
url="https://en.wikipedia.org/wiki/Code_injection#Shell_injection"
),
Reference(url="https://stackoverflow.com/a/3172488"),
Reference(url="https://cwe.mitre.org/data/definitions/78.html"),
Reference(url="https://cwe.mitre.org/data/definitions/78"),
],
),
transformer=LibcstTransformerPipeline(SubprocessShellFalseTransformer),
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/upgrade_sslcontext_minimum_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UpgradeSSLContextMinimumVersion(SimpleCodemod, NameResolutionMixin):
),
Reference(url="https://datatracker.ietf.org/doc/rfc8996/"),
Reference(url="https://www.digicert.com/blog/depreciating-tls-1-0-and-1-1"),
Reference(url="https://cwe.mitre.org/data/definitions/326.html"),
Reference(url="https://cwe.mitre.org/data/definitions/326"),
],
)
change_description = "Replaces minimum SSL/TLS version for SSLContext."
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/upgrade_sslcontext_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UpgradeSSLContextTLS(SimpleCodemod):
),
Reference(url="https://datatracker.ietf.org/doc/rfc8996/"),
Reference(url="https://www.digicert.com/blog/depreciating-tls-1-0-and-1-1"),
Reference(url="https://cwe.mitre.org/data/definitions/326.html"),
Reference(url="https://cwe.mitre.org/data/definitions/326"),
],
)
change_description = "Replaces known insecure TLS/SSL protocol versions in SSLContext with secure ones."
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/use_defused_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def dependency(self) -> Dependency:
Reference(
url="https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html"
),
Reference(url="https://cwe.mitre.org/data/definitions/611.html"),
Reference(url="https://cwe.mitre.org/data/definitions/611"),
],
),
transformer=LibcstTransformerPipeline(UseDefusedXmlTransformer),
Expand Down

0 comments on commit cafe85d

Please sign in to comment.