Skip to content

Adding action to mirror repo#27

Merged
advaitpatel merged 2 commits into
mainfrom
adding-action-to-mirror-repo
Mar 23, 2026
Merged

Adding action to mirror repo#27
advaitpatel merged 2 commits into
mainfrom
adding-action-to-mirror-repo

Conversation

@advaitpatel
Copy link
Copy Markdown
Collaborator

Pull Request

📝 Description

Please include a summary of the changes and the related issue. Include relevant motivation and context.

Fixes # (issue)

🎯 Type of Change

Please delete options that are not relevant:

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 Code style update (formatting, renaming)
  • ♻️ Code refactoring (no functional changes)
  • ⚡ Performance improvement
  • ✅ Test update
  • 🔧 Build/CI configuration
  • 🔒 Security fix

🧪 How Has This Been Tested?

Please describe the tests that you ran to verify your changes:

  • Test A
  • Test B

Test Configuration:

  • Python version:
  • Operating System:
  • DockSec version:

📋 Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have checked my code and corrected any misspellings

📸 Screenshots (if applicable)

Add screenshots to help explain your changes.

🔗 Related Issues/PRs

Link any related issues or pull requests:

  • Relates to #
  • Closes #
  • Depends on #

📚 Additional Notes

Any additional information that reviewers should know.


By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Comment on lines +12 to +78
runs-on: ubuntu-latest
name: Test Coverage Report

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Install package
run: |
pip install -e .

- name: Run tests with coverage
run: |
pytest tests/ --cov=. --cov-report=xml --cov-report=html --cov-report=term-missing || echo "Tests completed with coverage"
continue-on-error: true

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-docksec
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Upload coverage reports as artifact
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: |
coverage.xml
htmlcov/
if-no-files-found: ignore

- name: Generate Coverage Summary
run: |
echo "## Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f coverage.xml ]; then
echo "Coverage report generated successfully!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "📊 View detailed HTML report in artifacts" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Extract coverage percentage if available
if command -v coverage &> /dev/null; then
echo "### Coverage Details:" >> $GITHUB_STEP_SUMMARY
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY 2>/dev/null || echo "Run completed" >> $GITHUB_STEP_SUMMARY
fi
else
echo "⚠️ No coverage data generated" >> $GITHUB_STEP_SUMMARY
fi

- name: Coverage Badge
run: |
echo "Add this badge to your README.md:"
echo "[![codecov](https://codecov.io/gh/advaitpatel/DockSec/branch/main/graph/badge.svg)](https://codecov.io/gh/advaitpatel/DockSec)"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 2 months ago

Generally, the fix is to explicitly declare permissions for the workflow or job to follow the principle of least privilege, instead of relying on the repository’s default GITHUB_TOKEN permissions. For this coverage workflow, the minimal starting point is contents: read, which is sufficient for checking out and reading the repository. None of the steps need to push commits or modify repo metadata. Codecov’s action may need contents: read to read commit metadata, but not write access.

The best fix without changing functionality is to add a top-level permissions block right after the name: (or before jobs:) in .github/workflows/coverage.yml. This block will apply to all jobs in the workflow (there is only one, coverage). We will set permissions: contents: read, which aligns with the suggestion from CodeQL and GitHub’s guidance. No other code changes, imports, or job-step changes are required.

Concretely, in .github/workflows/coverage.yml, insert:

permissions:
  contents: read

between line 2 and line 3. This restricts GITHUB_TOKEN to read-only repository contents for this workflow, resolving the CodeQL finding while preserving existing behavior.

Suggested changeset 1
.github/workflows/coverage.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -1,5 +1,8 @@
 name: Code Coverage
 
+permissions:
+  contents: read
+
 on:
   push:
     branches: [ main ]
EOF
@@ -1,5 +1,8 @@
name: Code Coverage

permissions:
contents: read

on:
push:
branches: [ main ]
Copilot is powered by AI and may make mistakes. Always verify output.
@advaitpatel advaitpatel merged commit 36c2119 into main Mar 23, 2026
6 of 7 checks passed
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.

2 participants