-
Notifications
You must be signed in to change notification settings - Fork 9
Mucha dev gitlab security output #147
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
Open
+1,515
−16
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| # Test GitLab CI configuration for Socket Security Dashboard integration | ||
| # Rename to .gitlab-ci.yml to activate, or create a test pipeline in GitLab UI | ||
|
|
||
| stages: | ||
| - test | ||
| - security | ||
|
|
||
| # Test 1: Install from branch and generate report | ||
| socket_security_test: | ||
| stage: security | ||
| image: python:3.11 | ||
| before_script: | ||
| - pip install --upgrade pip | ||
| # Install directly from the git branch | ||
| - pip install git+https://github.com/SocketDev/socket-python-cli.git@mucha-dev-gitlab-security-output | ||
| script: | ||
| - echo "Testing GitLab Security Dashboard integration..." | ||
| - socketcli --version | ||
| - socketcli --help | grep "gitlab-security" | ||
| - | | ||
| socketcli \ | ||
| --api-token $SOCKET_API_TOKEN \ | ||
| --repo socket-python-cli \ | ||
| --target-path . \ | ||
| --enable-gitlab-security \ | ||
| --gitlab-security-file gl-dependency-scanning-report.json | ||
| - echo "Verifying report was generated..." | ||
| - ls -lh gl-dependency-scanning-report.json | ||
| - echo "Report contents preview:" | ||
| - cat gl-dependency-scanning-report.json | head -50 | ||
| artifacts: | ||
| reports: | ||
| dependency_scanning: gl-dependency-scanning-report.json | ||
| paths: | ||
| - gl-dependency-scanning-report.json | ||
| expire_in: 1 week | ||
| only: | ||
| - branches | ||
| allow_failure: false | ||
|
|
||
| # Test 2: Validate report schema | ||
| validate_gitlab_report: | ||
| stage: test | ||
| image: python:3.11 | ||
| dependencies: | ||
| - socket_security_test | ||
| script: | ||
| - echo "Validating GitLab Security report structure..." | ||
| - | | ||
| python3 << 'VALIDATE' | ||
| import json | ||
| import sys | ||
|
|
||
| with open('gl-dependency-scanning-report.json') as f: | ||
| report = json.load(f) | ||
|
|
||
| # Validate required fields | ||
| assert 'version' in report, "Missing 'version' field" | ||
| assert 'scan' in report, "Missing 'scan' field" | ||
| assert 'vulnerabilities' in report, "Missing 'vulnerabilities' field" | ||
|
|
||
| # Validate scan structure | ||
| scan = report['scan'] | ||
| assert scan['type'] == 'dependency_scanning', f"Invalid scan type: {scan['type']}" | ||
| assert 'analyzer' in scan, "Missing 'analyzer' in scan" | ||
| assert 'scanner' in scan, "Missing 'scanner' in scan" | ||
| assert scan['analyzer']['id'] == 'socket-security', "Invalid analyzer ID" | ||
| assert scan['scanner']['id'] == 'socket-cli', "Invalid scanner ID" | ||
|
|
||
| print(f"✓ Report structure is valid") | ||
| print(f"✓ Schema version: {report['version']}") | ||
| print(f"✓ Scan type: {scan['type']}") | ||
| print(f"✓ Vulnerabilities found: {len(report['vulnerabilities'])}") | ||
|
|
||
| if report['vulnerabilities']: | ||
| print(f"\nFirst 3 vulnerabilities:") | ||
| for i, vuln in enumerate(report['vulnerabilities'][:3], 1): | ||
| print(f" {i}. {vuln['severity']}: {vuln['name']}") | ||
| print(f" Package: {vuln['location']['dependency']['package']['name']}@{vuln['location']['dependency']['version']}") | ||
|
|
||
| print("\n✅ GitLab report validation successful!") | ||
| VALIDATE | ||
| only: | ||
| - branches | ||
|
|
||
| # Test 3: Multiple formats simultaneously | ||
| test_multiple_formats: | ||
| stage: security | ||
| image: python:3.11 | ||
| before_script: | ||
| - pip install git+https://github.com/SocketDev/socket-python-cli.git@mucha-dev-gitlab-security-output | ||
| script: | ||
| - echo "Testing multiple output formats..." | ||
| - | | ||
| socketcli \ | ||
| --api-token $SOCKET_API_TOKEN \ | ||
| --repo socket-python-cli \ | ||
| --target-path . \ | ||
| --enable-json \ | ||
| --enable-gitlab-security \ | ||
| --gitlab-security-file reports/gitlab-security.json > json-output.txt 2>&1 | ||
| - echo "Verifying both formats were generated..." | ||
| - ls -lh reports/gitlab-security.json | ||
| - grep -q "vulnerabilities" reports/gitlab-security.json && echo "✓ GitLab report contains vulnerabilities field" | ||
| - grep -q "scan_failed" json-output.txt && echo "✓ JSON output was generated" | ||
| artifacts: | ||
| paths: | ||
| - reports/gitlab-security.json | ||
| - json-output.txt | ||
| expire_in: 1 day | ||
| only: | ||
| - branches | ||
| allow_failure: true |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.