Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruff: Add and fix SIM117 #11653

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Ruff: Add and fix SIM117 #11653

wants to merge 1 commit into from

Conversation

kiblik
Copy link
Contributor

@kiblik kiblik commented Jan 25, 2025

Add rule multiple-with-statements (SIM117) and fix it.

Copy link

dryrunsecurity bot commented Jan 25, 2025

DryRun Security Summary

The pull request focuses on enhancing unit tests for various security-related parsers by improving code readability, error handling, and test coverage across multiple files, ensuring robust validation of different input scenarios and edge cases to maintain the application's security and stability.

Expand for full summary

Summary:

The code changes in this pull request are primarily focused on improving the unit tests for various security-related parsers used in the application. The changes cover a wide range of scenarios, including handling empty or invalid input files, processing files with different numbers of vulnerabilities, and validating the accuracy of the parsed data.

From an application security perspective, these changes are positive as they help to ensure the robustness and reliability of the security scanning functionality. By thoroughly testing the parsers' ability to handle a variety of input formats and edge cases, the changes contribute to the overall security and stability of the application.

The specific improvements include:

  • Consolidating with statements for better readability and error handling
  • Adding tests to cover scenarios like empty input files, files with no findings, and files with multiple findings
  • Verifying the parser's ability to correctly extract and process vulnerability details, such as titles, severities, CVEs, and file paths

Overall, these changes demonstrate a proactive approach to maintaining the security-related components of the application and should help to identify and address potential issues early in the development process.

Files Changed:

  • unittests/tools/test_aws_inspector2_parser.py: The changes consolidate the with statements for handling the test file and exception assertion, improving the code's readability.
  • unittests/tools/test_auditjs_parser.py: Similar changes are made to consolidate the with statements in the test cases.
  • unittests/tools/test_anchore_enterprise_parser.py: This file contains a comprehensive test suite for the AnchoreEnterpriseParser class, covering various scenarios related to parsing Anchore Enterprise security scan results.
  • ruff.toml: The changes in this file modify the configuration of the Ruff linter, removing the exclusion of a specific security-related linting rule and enabling autofixing for all enabled rules.
  • unittests/tools/test_coverity_api_parser.py: The changes focus on improving the error handling and testing different scenarios for the CoverityApiParser class.
  • unittests/tools/test_burp_graphql_parser.py: The changes consolidate the with statements in the test case for handling the expected ValueError exception.
  • unittests/tools/test_govulncheck_parser.py: The changes in this file demonstrate a comprehensive approach to testing the GovulncheckParser class, covering various edge cases and ensuring the parser can handle a wide range of input scenarios.
  • unittests/tools/test_intsights_parser.py: The changes consolidate the with statements in the test case for handling the expected ValueError exception.
  • unittests/tools/test_gitlab_api_fuzzing_parser.py: The changes improve the readability of the test case for handling invalid JSON input in the GitlabAPIFuzzingParser.
  • unittests/tools/test_kubehunter_parser.py: The changes focus on ensuring the robustness and reliability of the KubeHunterParser class, including handling empty input and multiple vulnerabilities.
  • unittests/tools/test_noseyparker_parser.py: The changes improve the readability and conciseness of the test case for handling errors in the NoseyParkerParser class.
  • unittests/tools/test_risk_recon_parser.py: The changes in this file ensure the reliability of the RiskReconParser class, including handling invalid API URLs and keys.
  • unittests/tools/test_meterian_parser.py: The changes in this file demonstrate a thorough approach to testing the MeterianParser class, covering various input scenarios and validating the accuracy of the parsed findings.
  • unittests/tools/test_threat_composer_parser.py: The changes improve the test case's handling of exceptions in the ThreatComposerParser class.
  • unittests/tools/test_yarn_audit_parser.py: The changes in this file ensure the YarnAuditParser class can handle a wide range of possible outputs from the yarn audit command, including edge cases and error conditions.
  • unittests/tools/test_sysdig_reports_parser.py: The changes focus on improving the test coverage and maintainability of the SysdigReportsParser class, including handling different input formats.
  • `unittests/tools/

Code Analysis

We ran 9 analyzers against 18 files and 0 analyzers had findings. 9 analyzers had no findings.

View PR in the DryRun Dashboard.

Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

Copy link
Contributor

@mtesauro mtesauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

Copy link
Contributor

github-actions bot commented Feb 3, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

github-actions bot commented Feb 3, 2025

Conflicts have been resolved. A maintainer will review the pull request shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants