📝 Add permissions needed for private repos#21
Conversation
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5 to 6. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@v5...v6) --- updated-dependencies: - dependency-name: actions/setup-python dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
[skip ci]
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@v4...v5) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: KhulnaSoft bot <43526132+khulnasoft-bot@users.noreply.github.com>
[skip ci]
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
[skip ci]
Signed-off-by: KhulnaSoft bot <43526132+khulnasoft-bot@users.noreply.github.com>
[skip ci]
Signed-off-by: KhulnaSoft bot <43526132+khulnasoft-bot@users.noreply.github.com>
Signed-off-by: KhulnaSoft bot <43526132+khulnasoft-bot@users.noreply.github.com>
[skip ci]
Signed-off-by: KhulnaSoft bot <43526132+khulnasoft-bot@users.noreply.github.com>
[skip ci]
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@v5...v6) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: KhulnaSoft bot <43526132+khulnasoft-bot@users.noreply.github.com>
[skip ci]
Bumps [actions/cache](https://github.com/actions/cache) from 4 to 5. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](actions/cache@v4...v5) --- updated-dependencies: - dependency-name: actions/cache dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: KhulnaSoft bot <43526132+khulnasoft-bot@users.noreply.github.com>
[skip ci]
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v5...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: KhulnaSoft bot <43526132+khulnasoft-bot@users.noreply.github.com>
[skip ci]
Reviewer's GuideDocuments and configures the GitHub Action to work correctly with private repositories, aligns the README examples with required permissions, bumps several GitHub Actions to their latest major versions, and updates the bot git identity used when committing latest changes. Sequence diagram for latest-changes workflow with private repo permissionssequenceDiagram
actor Developer
participant GitHubActions
participant Job_latest_changes
participant actions_checkout
participant latest_changes_action
participant GitHubAPI
participant Git
Developer->>GitHubActions: Push to default branch / trigger workflow
GitHubActions->>Job_latest_changes: Start job latest-changes
Job_latest_changes->>Job_latest_changes: permissions pull-requests read
Job_latest_changes->>actions_checkout: Run actions/checkout@v6
actions_checkout-->>Job_latest_changes: Repository checked out
Job_latest_changes->>latest_changes_action: Run khulnasoft/latest-changes
latest_changes_action->>GitHubAPI: List pull requests (requires pull-requests read)
GitHubAPI-->>latest_changes_action: Pull request data
latest_changes_action->>Git: git config user.name github-actions[bot]
latest_changes_action->>Git: git config user.email github-actions[bot]@users.noreply.github.com
latest_changes_action->>Git: Commit latest changes
latest_changes_action->>GitHubAPI: Push commit to repository
GitHubAPI-->>Developer: Latest changes available in repository
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 5 minutes and 47 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughUpdates GitHub Actions action versions, adds job-level workflow permissions for pull request access in examples, adjusts Git bot commit identity in the automation script, and records these changes in README release notes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- For the updated GitHub Actions git user, consider using the standard bot noreply email format (e.g.
41898282+github-actions[bot]@users.noreply.github.com) so commits are correctly attributed to thegithub-actions[bot]account.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- For the updated GitHub Actions git user, consider using the standard bot noreply email format (e.g. `41898282+github-actions[bot]@users.noreply.github.com`) so commits are correctly attributed to the `github-actions[bot]` account.
## Individual Comments
### Comment 1
<location path=".github/workflows/latest-changes.yml" line_range="19" />
<code_context>
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v5
+ - uses: actions/checkout@v6
- name: Dump GitHub context
env:
</code_context>
<issue_to_address>
**issue (bug_risk):** The `actions/checkout@v6` tag may not exist and could cause the workflow to fail.
`actions/checkout` is currently published up to `v4` (with `v4.x.x` tags). Using `@v6` will fail with `Resource not found` until that version exists. Please pin to the latest available major (e.g., `@v4`) or a specific `v4.x.x` tag instead.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: actions/checkout@v6 |
There was a problem hiding this comment.
issue (bug_risk): The actions/checkout@v6 tag may not exist and could cause the workflow to fail.
actions/checkout is currently published up to v4 (with v4.x.x tags). Using @v6 will fail with Resource not found until that version exists. Please pin to the latest available major (e.g., @v4) or a specific v4.x.x tag instead.
There was a problem hiding this comment.
| - uses: actions/checkout@v6 | |
| - uses: actions/checkout@v6 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@latest_changes/main.py`:
- Around line 236-239: Resolve the git executable once using shutil.which at
module startup (e.g., assign git_cmd = shutil.which("git") and raise a clear
error if None), import shutil if not present, and then replace all
subprocess.run invocations that currently pass the bare "git" string with the
resolved git_cmd variable (apply to the six subprocess.run calls shown in
main.py such as the git config and other git operations). Ensure each subprocess
call builds its argument list starting with git_cmd instead of "git" so PATH
lookup is avoided.
In `@README.md`:
- Around line 329-332: Update the "How does it work?" section text to reflect
the new bot identity by replacing occurrences of "github-actions" and
"github-actions@github.com" with "github-actions[bot]" and
"github-actions[bot]@users.noreply.github.com" respectively (search for the "How
does it work?" heading and the lines describing commit authorship to locate the
text to change).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b9d58928-0b87-4238-a255-16c618b50be7
📒 Files selected for processing (4)
.github/workflows/latest-changes.yml.github/workflows/test.ymlREADME.mdlatest_changes/main.py
| subprocess.run(["git", "config", "user.name", "github-actions[bot]"], check=True) | ||
| subprocess.run( | ||
| ["git", "config", "user.email", "github-actions@github.com"], check=True | ||
| ["git", "config", "user.email", "github-actions[bot]@users.noreply.github.com"], check=True | ||
| ) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify all subprocess git invocations still use bare "git" and should be migrated.
rg -nP --type=py 'subprocess\.run\(\[\s*"git"' latest_changes/main.pyRepository: khulnasoft/latest-changes
Length of output: 479
Harden all git subprocess calls by resolving the executable path once.
The file contains 6 subprocess.run calls using bare "git" (lines 236, 247, 261, 264, 269, 270), which rely on PATH lookup and trigger Ruff S607. Resolve the executable path once at startup using shutil.which() and reuse it for all git invocations.
Suggested hardening approach
+import shutil
...
+ git_bin = shutil.which("git")
+ if not git_bin:
+ logging.error("`git` executable not found in PATH")
+ sys.exit(1)
+
logging.info("Setting up GitHub Actions git user")
- subprocess.run(["git", "config", "user.name", "github-actions[bot]"], check=True)
+ subprocess.run([git_bin, "config", "user.name", "github-actions[bot]"], check=True)
subprocess.run(
- ["git", "config", "user.email", "github-actions[bot]@users.noreply.github.com"], check=True
+ [git_bin, "config", "user.email", "github-actions[bot]@users.noreply.github.com"], check=True
)Apply the same pattern to remaining git calls at lines 247, 261, 264, 269, and 270.
🧰 Tools
🪛 Ruff (0.15.7)
[error] 236-236: Starting a process with a partial executable path
(S607)
[error] 238-238: Starting a process with a partial executable path
(S607)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@latest_changes/main.py` around lines 236 - 239, Resolve the git executable
once using shutil.which at module startup (e.g., assign git_cmd =
shutil.which("git") and raise a clear error if None), import shutil if not
present, and then replace all subprocess.run invocations that currently pass the
bare "git" string with the resolved git_cmd variable (apply to the six
subprocess.run calls shown in main.py such as the git config and other git
operations). Ensure each subprocess call builds its argument list starting with
git_cmd instead of "git" so PATH lookup is avoided.
| #### Features | ||
|
|
||
| * 🔧 Update GitHub Actions bot user configuration. PR [#5](https://github.com/khulnasoft-bot/latest-changes/pull/5) by [@khulnasoft-bot](https://github.com/khulnasoft-bot). | ||
|
|
There was a problem hiding this comment.
Update README bot identity text to match this new release-note entry.
This section now documents the bot-user-config change, but the “How does it work?” section still says commits are authored as github-actions / github-actions@github.com. Please align that text with github-actions[bot] and github-actions[bot]@users.noreply.github.com.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@README.md` around lines 329 - 332, Update the "How does it work?" section
text to reflect the new bot identity by replacing occurrences of
"github-actions" and "github-actions@github.com" with "github-actions[bot]" and
"github-actions[bot]@users.noreply.github.com" respectively (search for the "How
does it work?" heading and the lines describing commit authorship to locate the
text to change).
…h once. Signed-off-by: KhulnaSoft bot <43526132+khulnasoft-bot@users.noreply.github.com>
|
|
||
| logging.info("Setting up GitHub Actions git user") | ||
| subprocess.run(["git", "config", "user.name", "github-actions"], check=True) | ||
| subprocess.run([git_bin, "config", "user.name", "github-actions[bot]"], check=True) |
There was a problem hiding this comment.
security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.
Source: opengrep
| subprocess.run( | ||
| ["git", "config", "user.email", "github-actions@github.com"], check=True | ||
| [git_bin, "config", "user.email", "github-actions[bot]@users.noreply.github.com"], check=True | ||
| ) |
There was a problem hiding this comment.
security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.
Source: opengrep
There was a problem hiding this comment.
♻️ Duplicate comments (1)
latest_changes/main.py (1)
236-238:⚠️ Potential issue | 🔴 Critical
git_binis undefined here, and the hardening migration is incomplete.Line 236 and Line 238 use
git_bin, but no variable is defined in the file, somain()will fail at runtime. Also, remaining git calls still use bare"git"(Lines 247, 259, 261, 264, 269, 270), so the PATH-hardening objective is only partially applied.Proposed fix
import logging import re +import shutil import subprocess import sys @@ def main() -> None: + git_bin = shutil.which("git") + if not git_bin: + logging.error("`git` executable not found in PATH") + sys.exit(1) + @@ - subprocess.run(["git", "pull"], check=True) + subprocess.run([git_bin, "pull"], check=True) @@ - subprocess.run( - ["git", "add", str(settings.input_latest_changes_file)], check=True - ) - subprocess.run(["git", "commit", "-m", COMMIT_MESSAGE], check=True) + subprocess.run([git_bin, "add", str(settings.input_latest_changes_file)], check=True) + subprocess.run([git_bin, "commit", "-m", COMMIT_MESSAGE], check=True) @@ - result = subprocess.run(["git", "push"]) + result = subprocess.run([git_bin, "push"]) @@ - subprocess.run(["git", "reset", "HEAD^1"], check=True) - subprocess.run(["git", "checkout", "."], check=True) + subprocess.run([git_bin, "reset", "HEAD^1"], check=True) + subprocess.run([git_bin, "checkout", "."], check=True)#!/bin/bash # Verify `git_bin` is defined and all subprocess git calls use it. set -euo pipefail echo "== Check definition of git_bin ==" rg -nP --type=py '\bgit_bin\s*=' latest_changes/main.py || true echo "== Check subprocess calls still using bare \"git\" ==" rg -nP --type=py 'subprocess\.run\(\[\s*"git"' latest_changes/main.py || true🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@latest_changes/main.py` around lines 236 - 238, The code fails because git_bin is never defined and some subprocess.run calls still use the literal "git", so update main() to define git_bin (e.g., resolve the git binary via shutil.which("git") with a sensible fallback or raise a clear error) before any subprocess.run usage, then replace every subprocess.run([... "git", ...]) invocation (all occurrences that call subprocess.run with "git" such as the calls currently at/near the blocks configuring user.name/email and the other git invocations) to use the git_bin variable instead of the literal "git"; ensure you import any helper (shutil/os) needed and keep git_bin in scope for all places that call subprocess.run.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@latest_changes/main.py`:
- Around line 236-238: The code fails because git_bin is never defined and some
subprocess.run calls still use the literal "git", so update main() to define
git_bin (e.g., resolve the git binary via shutil.which("git") with a sensible
fallback or raise a clear error) before any subprocess.run usage, then replace
every subprocess.run([... "git", ...]) invocation (all occurrences that call
subprocess.run with "git" such as the calls currently at/near the blocks
configuring user.name/email and the other git invocations) to use the git_bin
variable instead of the literal "git"; ensure you import any helper (shutil/os)
needed and keep git_bin in scope for all places that call subprocess.run.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3524425a-23d1-48d0-aa5c-52a9577c6624
📒 Files selected for processing (1)
latest_changes/main.py
📝 Add permissions needed for private repos
Summary by Sourcery
Document required GitHub Actions permissions for using the action with private repositories, align bot git user configuration with the GitHub Actions bot identity, and update GitHub Actions dependencies to their latest major versions.
Enhancements:
CI:
Documentation:
Tests:
Summary by CodeRabbit
Chores
Documentation