-
Notifications
You must be signed in to change notification settings - Fork 65
Adding action to mirror repo #27
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 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,47 @@ | ||
| version: 2 | ||
|
|
||
| updates: | ||
| # Python dependencies | ||
| - package-ecosystem: "pip" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| day: "monday" | ||
| time: "06:00" | ||
| open-pull-requests-limit: 10 | ||
| reviewers: | ||
| - "advaitpatel" | ||
| labels: | ||
| - "dependencies" | ||
| - "python" | ||
| commit-message: | ||
| prefix: "chore(deps)" | ||
| include: "scope" | ||
| # Group minor and patch updates together | ||
| groups: | ||
| langchain: | ||
| patterns: | ||
| - "langchain*" | ||
| development: | ||
| patterns: | ||
| - "pytest*" | ||
| - "black" | ||
| - "ruff" | ||
| - "mypy" | ||
|
|
||
| # GitHub Actions | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| day: "monday" | ||
| time: "06:00" | ||
| open-pull-requests-limit: 5 | ||
| reviewers: | ||
| - "advaitpatel" | ||
| labels: | ||
| - "dependencies" | ||
| - "github-actions" | ||
| commit-message: | ||
| prefix: "chore(ci)" | ||
| include: "scope" |
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,44 @@ | ||
| name: "CodeQL Security Scanning" | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
| schedule: | ||
| # Run every Monday at 6:00 AM UTC | ||
| - cron: '0 6 * * 1' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| analyze: | ||
| name: Analyze Code | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| security-events: write | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| language: [ 'python' ] | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@v3 | ||
| with: | ||
| languages: ${{ matrix.language }} | ||
| # Run additional queries for comprehensive security analysis | ||
| queries: +security-extended,security-and-quality | ||
|
|
||
| - name: Autobuild | ||
| uses: github/codeql-action/autobuild@v3 | ||
|
|
||
| - name: Perform CodeQL Analysis | ||
| uses: github/codeql-action/analyze@v3 | ||
| with: | ||
| category: "/language:${{matrix.language}}" |
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,78 @@ | ||
| name: Code Coverage | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| coverage: | ||
| 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 "[](https://codecov.io/gh/advaitpatel/DockSec)" | ||
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.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 2 months ago
Generally, the fix is to explicitly declare
permissionsfor the workflow or job to follow the principle of least privilege, instead of relying on the repository’s defaultGITHUB_TOKENpermissions. For this coverage workflow, the minimal starting point iscontents: 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 needcontents: readto read commit metadata, but not write access.The best fix without changing functionality is to add a top-level
permissionsblock right after thename:(or beforejobs:) in.github/workflows/coverage.yml. This block will apply to all jobs in the workflow (there is only one,coverage). We will setpermissions: 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:between line 2 and line 3. This restricts
GITHUB_TOKENto read-only repository contents for this workflow, resolving the CodeQL finding while preserving existing behavior.