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

Add CI/CD parameters to scan creation API and CLI #857

Merged

Conversation

oussamaessaji
Copy link
Member

@oussamaessaji oussamaessaji commented Jan 21, 2025

The changes introduce CI/CD context tracking for scans initiated from GitHub Actions by incorporating support for CI/CD parameters throughout the scan creation process. A new ScanSource data class has been created to hold CI/CD-related information, including the source, repository, and pull request ID. Additionally, the mobile scan API request has been updated to accept and include these parameters in the GraphQL query and its variables.

Changed files

scan_create.py:

• Added ScanSource dataclass to hold CI/CD related parameters (source, repository, pr_id)
• Updated CreateMobileScanAPIRequest to:
• Accept ci_cd_params parameter
• Include CI/CD parameters in GraphQL query and variables
• Pass CI/CD params to API request data

run.py:

• Added new CLI options for CI/CD parameters:
• --source: CI/CD source name
• --repository: Repository name
• --pr-number: Pull request number
• Stored CI/CD parameters in context object for passing to scan creation

mobile.py:

• Updated run_mobile_scan to:
• Get CI/CD params from context
• Create ScanSource instance if source is provided
• Pass CI/CD params to _create_scan
• Updated _create_scan to:
• Accept ci_cd_params parameter
• Pass CI/CD params to API request

@oussamaessaji oussamaessaji requested a review from a team as a code owner January 21, 2025 17:28
Copy link

@ostorlab-ai-pr-review ostorlab-ai-pr-review bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

Total Issues Found: 4
Critical Issues: 1
Suggestions: 3

Key Findings:
The code review identified several issues and suggestions across multiple files. Key themes include the need for better handling of default values, modernizing type hints, and improving code readability. The most critical issue is the potential runtime error due to the unhandled None value for ci_cd_params. Overall, the code quality is good but could benefit from some improvements in type hinting and error handling.

Overall Assessment:
The code quality is needs improvement. The code review identified several issues and suggestions across multiple files. Key themes include the need for better handling of default values, modernizing type hints, and improving code readability. The most critical issue is the potential runtime error due to the unhandled None value for ci_cd_params. Overall, the code quality is good but could benefit from some improvements in type hinting and error handling.

src/ostorlab/apis/scan_create.py Outdated Show resolved Hide resolved
src/ostorlab/cli/ci_scan/run/assets/mobile.py Show resolved Hide resolved
src/ostorlab/cli/ci_scan/run/run.py Show resolved Hide resolved
tests/cli/ci_scan/run/run_test.py Outdated Show resolved Hide resolved
@oussamaessaji oussamaessaji marked this pull request as draft January 22, 2025 08:20
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 63.63636% with 12 lines in your changes missing coverage. Please review.

Project coverage is 62.87%. Comparing base (fa1dbd5) to head (e7a10d1).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/ostorlab/apis/scan_create.py 14.28% 6 Missing ⚠️
src/ostorlab/cli/ci_scan/run/run.py 42.85% 4 Missing ⚠️
src/ostorlab/cli/ci_scan/run/assets/mobile.py 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #857      +/-   ##
==========================================
+ Coverage   62.27%   62.87%   +0.59%     
==========================================
  Files         342      342              
  Lines       14566    14596      +30     
==========================================
+ Hits         9071     9177     +106     
+ Misses       5495     5419      -76     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@oussamaessaji oussamaessaji marked this pull request as ready for review January 22, 2025 14:45
src/ostorlab/apis/scan_create.py Outdated Show resolved Hide resolved
src/ostorlab/cli/ci_scan/run/assets/mobile.py Outdated Show resolved Hide resolved
Co-authored-by: Mohamed Elyousfi <144013278+elyousfi5@users.noreply.github.com>
3asm
3asm previously requested changes Jan 22, 2025
Copy link
Member

@3asm 3asm left a comment

Choose a reason for hiding this comment

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

Naming is the main thing to fix.

src/ostorlab/apis/scan_create.py Outdated Show resolved Hide resolved
src/ostorlab/apis/scan_create.py Show resolved Hide resolved
@amine3 amine3 dismissed 3asm’s stale review January 23, 2025 09:27

Changes applied

@amine3 amine3 merged commit 6dfe38a into main Jan 23, 2025
12 checks passed
@amine3 amine3 deleted the feature/-Add-CI/CD-parameters-to-scan-creation-API-and-CLI branch January 23, 2025 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants