Feature/add status sh file - #25
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdded Bash encryption and decryption utilities, expanded PowerShell cleanup scripts, standardized Bash shebangs, updated NordVPN authentication and Meshnet handling, added lint workflows, and expanded the README. ChangesEncryption utilities
PowerShell cleanup tools
Bash portability and Meshnet scripts
Repository quality checks and documentation
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant encrypt_file.sh
participant OpenSSL
participant decrypt_file.sh
User->>encrypt_file.sh: provide input file and passphrase
encrypt_file.sh->>OpenSSL: encrypt with AES-256-CBC and PBKDF2
OpenSSL-->>encrypt_file.sh: write encrypted output
User->>decrypt_file.sh: provide encrypted file and passphrase
decrypt_file.sh->>OpenSSL: decrypt with AES-256-CBC and PBKDF2
OpenSSL-->>decrypt_file.sh: write decrypted output
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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.
Actionable comments posted: 20
🧹 Nitpick comments (3)
.github/workflows/lint.yml (1)
16-16: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winPin action references to immutable commits.
The workflow uses mutable tag references. Pin each action to a full commit SHA. Keep the release tag in a comment for maintenance.
Also applies to: 19-19, 29-29, 32-32
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/lint.yml at line 16, Update every action reference in the workflow, including the actions/checkout@v4 entry and the additional action uses, to a full immutable commit SHA. Preserve each current release tag in an adjacent comment for maintenance and traceability.PowerShell/DeleteEmptyFolders.ps1 (1)
1-4: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winComplete the comment-based help in both wrappers. Both blocks stop after
.SYNOPSIS.
PowerShell/DeleteEmptyFolders.ps1#L1-L4: add.DESCRIPTION,.PARAMETER Path, and examples for deletion,-WhatIf, and-Confirm.PowerShell/FindEmptySubDirectories.ps1#L1-L4: add.DESCRIPTION,.PARAMETER Path, and an example showing read-only listing.As per coding guidelines, preserve help comment blocks (
.SYNOPSIS/.DESCRIPTION/.PARAMETER/.EXAMPLE) when editing PowerShell files.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@PowerShell/DeleteEmptyFolders.ps1` around lines 1 - 4, Complete the comment-based help blocks in PowerShell/DeleteEmptyFolders.ps1 and PowerShell/FindEmptySubDirectories.ps1. In both wrappers, retain the existing .SYNOPSIS and add .DESCRIPTION plus .PARAMETER Path; add deletion, -WhatIf, and -Confirm examples in DeleteEmptyFolders.ps1, and a read-only listing example in FindEmptySubDirectories.ps1.Source: Coding guidelines
PowerShell/DeleteFiles.ps1 (1)
35-56: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftExtract the implementation from this top-level script.
This file contains parameter handling, file selection, and deletion. Move the reusable logic into a
*.Function.ps1function. KeepPowerShell/DeleteFiles.ps1as the CLI wrapper and preserve itsShouldProcessbehavior.As per coding guidelines,
PowerShell/!(*.Function).ps1scripts should be thin wrappers around reusable logic and honor-WhatIf/-Confirm.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@PowerShell/DeleteFiles.ps1` around lines 35 - 56, Extract the parameter-driven file selection and deletion logic from the top-level script into a reusable function in a corresponding *.Function.ps1 file, including the existing filtering, reporting, and ShouldProcess behavior. Keep DeleteFiles.ps1 as a thin CLI wrapper that accepts the parameters and invokes the function, preserving -WhatIf and -Confirm support through the function’s CmdletBinding/SupportsShouldProcess configuration.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/lint.yml:
- Around line 3-7: Update the workflow trigger configuration under on in
lint.yml to run for every push and pull_request by removing both branches
filters, matching the documented CI scope in README.md.
- Around line 1-3: Update the workflow-level configuration in “Lint Scripts” to
explicitly set GITHUB_TOKEN permissions with contents read access, ensuring all
unspecified permissions remain unavailable while preserving the existing lint
behavior.
- Around line 15-16: Update both actions/checkout@v4 steps in the workflow to
set persist-credentials to false, ensuring the static-analysis jobs do not
retain GitHub credentials after checkout.
In `@bash/encryption/encrypt_file.sh`:
- Around line 1-2: Set umask 077 immediately after the shell setup in
bash/encryption/encrypt_file.sh (lines 1-2), before encryption output creation;
apply the same change in bash/encryption/decrypt_file.sh (lines 1-2), before
plaintext output creation, so both scripts create files with owner-only
permissions.
- Around line 4-12: Update the argument parsing in
bash/encryption/encrypt_file.sh lines 4-12 and bash/encryption/decrypt_file.sh
lines 4-12 so each script accepts exactly one or two arguments, rejects counts
outside that range, and treats -h or --help as successful help requests with
exit status 0 rather than errors. Preserve the documented usage output and apply
the same validation behavior in both scripts.
- Line 37: Update the encryption/decryption flow around the OpenSSL commands in
bash/encryption/encrypt_file.sh lines 37-37 and bash/encryption/decrypt_file.sh
lines 36-36 to use a coordinated authenticated format: encrypt_file.sh must
produce ciphertext with an authentication tag or encrypt-then-MAC, and
decrypt_file.sh must verify authentication before releasing any plaintext,
rejecting tampered data.
- Line 37: Replace the pass: command arguments in the OpenSSL invocations with
stdin or a dedicated file descriptor: update the encrypt command in
bash/encryption/encrypt_file.sh lines 37-37 to use PASS1 securely, and update
the decrypt command in bash/encryption/decrypt_file.sh lines 36-36 to use PASS
securely. Ensure both commands avoid exposing passphrases through process
arguments.
- Line 20: Prevent direct writes to user-selected paths in
bash/encryption/encrypt_file.sh:20-20 and bash/encryption/encrypt_file.sh:37-37
by rejecting existing or identical output paths, selecting a temporary
destination, encrypting into it, and renaming only after successful completion
with cleanup traps. In bash/encryption/decrypt_file.sh:20-26, reject empty,
existing, or identical output paths; in bash/encryption/decrypt_file.sh:36-40,
ensure failure cleanup removes only the temporary output and publish the final
file only after authenticated decryption succeeds.
In `@bash/nord/copy_scripts.sh`:
- Line 15: Update copy_scripts.sh so the peers.json source is resolved relative
to the script’s own location using BASH_SOURCE[0], rather than the caller’s
working directory. Copy that resolved source to ~/.local/bin/peers.json and make
the script fail if the copy command fails.
In `@bash/nord/login.sh`:
- Line 3: Remove the hardcoded credential from the NordVPN login command. Update
the login flow to obtain the token from a protected secret or interactive prompt
without exposing it in the script or process arguments, and revoke and rotate
the existing token separately.
In `@bash/nord/reset.sh`:
- Around line 1-4: Update the commands invoked by the reset script to use the
installed dependency names nord_logout, nord_login, and nord_connect instead of
relative logout.sh, login.sh, and connect.sh paths, so nord_reset works from any
directory.
In `@PowerShell/DeleteEmptyFolders.ps1`:
- Around line 5-11: Update the wrapper around the child-script invocation in
DeleteEmptyFolders.ps1 to call $PSCmdlet.ShouldProcess() before deletion, using
the target path and a descriptive action. Invoke ManageEmptyFolders.ps1 only
when approved, and pass -Confirm:$false so inherited confirmation preferences do
not trigger a second prompt.
In `@PowerShell/DeleteFiles.ps1`:
- Around line 21-22: Validate the DaysOld parameter in the DeleteFiles script
and reject values below zero before calculating $cutoffDate. Preserve the
existing behavior for zero and positive values, and provide a clear validation
error for negative input.
- Around line 28-39: Update the path validation to use Test-Path with
-LiteralPath $Path and -PathType Container, ensuring the target is an existing
directory rather than a file or wildcard pattern. In the $getParams used by
Get-ChildItem, replace Path with LiteralPath while preserving the existing
Filter, File, and Recurse options.
- Around line 52-54: Update the Remove-Item call within the ShouldProcess block
to use terminating error behavior, such as ErrorAction Stop, so failures prevent
execution from reaching the Write-Host success message. Keep the existing
deletion and success-reporting flow unchanged for successful removals.
- Around line 35-42: Update the Get-ChildItem invocation used to populate
$filesToDelete with -ErrorAction Stop, and wrap that enumeration in error
handling that exits or otherwise prevents the deletion loop from running when an
error occurs. Preserve the existing filtering and deletion behavior for
successful enumeration.
- Around line 52-53: Update the Remove-Item invocation within the ShouldProcess
deletion block to use -LiteralPath instead of -Path with $file.FullName,
ensuring wildcard characters are treated literally and only the selected file is
deleted.
In `@README.md`:
- Line 105: Update the GitHub Actions link in the README to use the
repository-relative path .github/workflows/lint.yml instead of the local file://
URI, preserving the surrounding description.
- Line 9: Update the repository-tree fenced code block in the README to specify
the text language, changing the unlabeled fence to a text-labeled fence so
markdownlint MD040 passes.
- Around line 86-90: Update the destructive ManageEmptyFolders.ps1 README
example to include the -Confirm switch with -Delete, and update the dry-run
example if needed to keep the documented command behavior consistent.
---
Nitpick comments:
In @.github/workflows/lint.yml:
- Line 16: Update every action reference in the workflow, including the
actions/checkout@v4 entry and the additional action uses, to a full immutable
commit SHA. Preserve each current release tag in an adjacent comment for
maintenance and traceability.
In `@PowerShell/DeleteEmptyFolders.ps1`:
- Around line 1-4: Complete the comment-based help blocks in
PowerShell/DeleteEmptyFolders.ps1 and PowerShell/FindEmptySubDirectories.ps1. In
both wrappers, retain the existing .SYNOPSIS and add .DESCRIPTION plus
.PARAMETER Path; add deletion, -WhatIf, and -Confirm examples in
DeleteEmptyFolders.ps1, and a read-only listing example in
FindEmptySubDirectories.ps1.
In `@PowerShell/DeleteFiles.ps1`:
- Around line 35-56: Extract the parameter-driven file selection and deletion
logic from the top-level script into a reusable function in a corresponding
*.Function.ps1 file, including the existing filtering, reporting, and
ShouldProcess behavior. Keep DeleteFiles.ps1 as a thin CLI wrapper that accepts
the parameters and invokes the function, preserving -WhatIf and -Confirm support
through the function’s CmdletBinding/SupportsShouldProcess configuration.
🪄 Autofix
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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b7346073-c3ec-4d3a-b3c7-2c64f7928cf6
📒 Files selected for processing (22)
.github/workflows/lint.ymlPowerShell/DeleteEmptyFolders.ps1PowerShell/DeleteFiles.ps1PowerShell/FindEmptySubDirectories.ps1PowerShell/FindEmptySubDirectories.txtPowerShell/ManageEmptyFolders.ps1PowerShell/ManageEmptyFolders2.ps1README.mdbash/AutoRemoveSnapd.shbash/countLines.shbash/encryption/decrypt_file.shbash/encryption/encrypt_file.shbash/nord/config.shbash/nord/connect.shbash/nord/copy_scripts.shbash/nord/exit_node.shbash/nord/list_peers.shbash/nord/login.shbash/nord/logout.shbash/nord/nord_watchdog.shbash/nord/reset.shbash/nord/set_nickname.sh
💤 Files with no reviewable changes (2)
- PowerShell/ManageEmptyFolders2.ps1
- PowerShell/FindEmptySubDirectories.txt
| name: Lint Scripts | ||
|
|
||
| on: |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- workflow files ---'
git ls-files '.github/workflows/*' | sort
printf '%s\n' '--- lint workflow ---'
cat -n .github/workflows/lint.yml
printf '%s\n' '--- repository permission declarations ---'
rg -n --glob '.github/workflows/*.yml' --glob '.github/workflows/*.yaml' '^[[:space:]]*permissions:|^[[:space:]]*(contents|actions|checks|pull-requests):' .github/workflows || true
printf '%s\n' '--- lint workflow references and documentation ---'
rg -n -C 3 'Lint Scripts|lint\.yml|checks run|every push|pull request|GITHUB_TOKEN|permissions' README.md .github . 2>/dev/null | head -250Repository: terjeinnerdal/scripts
Length of output: 7842
🌐 Web query:
site:docs.github.com GitHub Actions GITHUB_TOKEN permissions unspecified permissions contents read default repository organization settings
💡 Result:
When you explicitly define the permissions key in a GitHub Actions workflow file, any permissions not listed in that key are automatically set to none (no access), with the sole exception of the metadata scope, which always retains read access [1][2]. This behavior applies whether you are configuring permissions at the workflow level or the job level [1]. By default, if the permissions key is omitted entirely, the GITHUB_TOKEN receives permissions based on the settings configured at the enterprise, organization, or repository level [1][3][4]. These repository and organization settings offer two primary modes [5][6]: 1. Permissive: Grants read/write access to most scopes, including contents and packages. 2. Restricted: Limits the GITHUB_TOKEN to read-only access for contents and packages, with all other scopes set to none. Because the explicit use of the permissions key overrides these defaults and sets unspecified permissions to none, it is considered a security best practice to use this key to follow the principle of least privilege, explicitly granting only the access required for your specific workflow or job [7][1][2].
Citations:
- 1: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax
- 2: https://docs.github.com/en/enterprise-server@3.13/actions/security-guides/automatic-token-authentication
- 3: https://docs.github.com/en/enterprise-server@3.2/actions/reference/authentication-in-a-workflow
- 4: https://docs.github.com/en/enterprise-server@3.4/actions/security-guides/automatic-token-authentication
- 5: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository
- 6: https://docs.github.com/en/organizations/managing-organization-settings/disabling-or-limiting-github-actions-for-your-organization
- 7: https://docs.github.com/en/actions/tutorials/authenticate-with-github_token
🌐 Web query:
site:github.com/actions/checkout README token contents read permission
💡 Result:
The phrase "README token contents read permission" refers to a common configuration requirement for GitHub Actions workflows, specifically when using the actions/checkout action [1][2][3]. In GitHub Actions, when you define the permissions key within a workflow file, all permissions not explicitly specified are set to none [4]. Because the actions/checkout action requires access to the repository's files to clone them, it specifically necessitates the contents: read permission [1][5][6]. If you configure other permissions for your job (like pages: write or id-token: write) but fail to include contents: read, the checkout action will fail because the GITHUB_TOKEN used by the runner will lack the necessary access to read the repository's contents [4][6]. To ensure the action functions correctly, it is recommended to include the following in your workflow YAML [1][7][3]: permissions: contents: read This setting provides the minimum required scope for the action to pull the code from the repository [8][3]. If you are using a Personal Access Token (PAT) instead of the default GITHUB_TOKEN, that token must also be granted at least read access to Contents and Metadata [8].
Citations:
- 1: https://github.com/actions/checkout/blob/main/README.md
- 2: https://www.github.com/actions/checkout
- 3: https://github.com/actions/checkout/?tab=readme-ov-file
- 4: Failing to checkout private repo actions/checkout#985
- 5: actions/checkout@009b9ae
- 6: Not always working on private repos actions/checkout#1850
- 7: https://github.com/actions/checkout/tree/v6.0.2?tab=readme-ov-file
- 8: Document how to clone with a PAT as a read-only action actions/checkout#779
🏁 Script executed:
#!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path
import re
path = Path(".github/workflows/lint.yml")
text = path.read_text()
print("permissions_key_present:", bool(re.search(r"(?m)^permissions:\s*$", text)))
print("github_token_references:", len(re.findall(r"GITHUB_TOKEN|github\.token", text)))
uses = re.findall(r"(?m)^\s*uses:\s*([^\s#]+)", text)
print("actions_used:", uses)
print("only_read_or_analysis_actions:", all(
action.startswith(("actions/checkout@", "ludeeus/action-shellcheck@", "microsoft/psscriptanalyzer-action@"))
for action in uses
))
PY
printf '%s\n' '--- public repository metadata ---'
curl -fsSL -H 'Accept: application/vnd.github+json' \
https://api.github.com/repos/terjeinnerdal/scripts |
jq '{private, visibility, default_branch, archived}'
printf '%s\n' '--- publicly accessible Actions permission metadata ---'
curl -fsSL -H 'Accept: application/vnd.github+json' \
https://api.github.com/repos/terjeinnerdal/scripts/actions/permissions |
jq '{enabled, default_workflow_permissions, can_approve_pull_request_reviews}' || trueRepository: terjeinnerdal/scripts
Length of output: 630
Restrict the workflow token permissions.
Because permissions is omitted, GITHUB_TOKEN uses repository, organization, or enterprise defaults, which can grant write access. The jobs only check out and analyze source files. Set workflow-level contents: read; unspecified permissions then remain unavailable.
🧰 Tools
🪛 zizmor (1.29.0)
[warning] 1-37: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/lint.yml around lines 1 - 3, Update the workflow-level
configuration in “Lint Scripts” to explicitly set GITHUB_TOKEN permissions with
contents read access, ensuring all unspecified permissions remain unavailable
while preserving the existing lint behavior.
Source: Linters/SAST tools
| on: | ||
| push: | ||
| branches: [ main, master, "feature/**" ] | ||
| pull_request: | ||
| branches: [ main, master ] |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Align the trigger filters with the documented CI scope.
README.md states that the checks run on every push and pull request. This workflow runs only on selected branches. Remove the branch filters if all refs are required. Otherwise, document the restricted scope in README.md.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/lint.yml around lines 3 - 7, Update the workflow trigger
configuration under on in lint.yml to run for every push and pull_request by
removing both branches filters, matching the documented CI scope in README.md.
| #!/usr/bin/env bash | ||
| set -euo pipefail |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Both scripts rely on the caller's umask when creating cryptographic output. Set umask 077 in both files before creating output.
bash/encryption/encrypt_file.sh#L1-L2: addumask 077before the encryption output is created.bash/encryption/decrypt_file.sh#L1-L2: addumask 077before the plaintext output is created.
📍 Affects 2 files
bash/encryption/encrypt_file.sh#L1-L2(this comment)bash/encryption/decrypt_file.sh#L1-L2
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@bash/encryption/encrypt_file.sh` around lines 1 - 2, Set umask 077
immediately after the shell setup in bash/encryption/encrypt_file.sh (lines
1-2), before encryption output creation; apply the same change in
bash/encryption/decrypt_file.sh (lines 1-2), before plaintext output creation,
so both scripts create files with owner-only permissions.
| usage() { | ||
| echo "Usage: $0 <input_file> [output_file]" | ||
| echo "Encrypts a file using AES-256-CBC with PBKDF2 key derivation." | ||
| exit 1 | ||
| } | ||
|
|
||
| if [[ $# -lt 1 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then | ||
| usage | ||
| fi |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Both command parsers report help as an error and ignore extra arguments. Return status 0 for help and reject argument counts outside the documented range.
bash/encryption/encrypt_file.sh#L4-L12: accept exactly one or two arguments and return 0 for-hand--help.bash/encryption/decrypt_file.sh#L4-L12: accept exactly one or two arguments and return 0 for-hand--help.
📍 Affects 2 files
bash/encryption/encrypt_file.sh#L4-L12(this comment)bash/encryption/decrypt_file.sh#L4-L12
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@bash/encryption/encrypt_file.sh` around lines 4 - 12, Update the argument
parsing in bash/encryption/encrypt_file.sh lines 4-12 and
bash/encryption/decrypt_file.sh lines 4-12 so each script accepts exactly one or
two arguments, rejects counts outside that range, and treats -h or --help as
successful help requests with exit status 0 rather than errors. Preserve the
documented usage output and apply the same validation behavior in both scripts.
| if ($PSCmdlet.ShouldProcess($file.FullName, "Delete file")) { | ||
| Remove-Item -Path $file.FullName -Force |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- file inventory ---'
git ls-files 'PowerShell/DeleteFiles.ps1'
printf '%s\n' '--- script outline ---'
if command -v ast-grep >/dev/null 2>&1; then
ast-grep outline PowerShell/DeleteFiles.ps1 --lang powershell || true
fi
printf '%s\n' '--- relevant source ---'
nl -ba PowerShell/DeleteFiles.ps1 | sed -n '1,130p'
printf '%s\n' '--- runtime availability ---'
command -v pwsh || true
command -v powershell || trueRepository: terjeinnerdal/scripts
Length of output: 457
🏁 Script executed:
#!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path
p = Path("PowerShell/DeleteFiles.ps1")
text = p.read_text()
for term in ("Remove-Item -Path", "Remove-Item -LiteralPath", "ShouldProcess", "Get-ChildItem"):
print(f"{term}: {text.count(term)} occurrence(s)")
PYRepository: terjeinnerdal/scripts
Length of output: 298
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- relevant source ---'
sed -n '1,130p' PowerShell/DeleteFiles.ps1
printf '%s\n' '--- PowerShell parameter semantics ---'
pwsh -NoProfile -NonInteractive -Command '
$cmd = Get-Command Remove-Item
$path = $cmd.Parameters["Path"]
$literal = $cmd.Parameters["LiteralPath"]
[pscustomobject]@{
PathPosition = $path.Attributes.Position
PathValueFromRemainingArguments = $path.Attributes.ValueFromRemainingArguments
LiteralPathPosition = $literal.Attributes.Position
LiteralPathValueFromRemainingArguments = $literal.Attributes.ValueFromRemainingArguments
} | Format-List
Get-Help Remove-Item -Parameter Path -ErrorAction SilentlyContinue |
Out-String -Width 200
Get-Help Remove-Item -Parameter LiteralPath -ErrorAction SilentlyContinue |
Out-String -Width 200
'Repository: terjeinnerdal/scripts
Length of output: 2563
🏁 Script executed:
#!/bin/bash
set -eu
pwsh -NoProfile -NonInteractive -Command '
Set-Location (Get-Location).Path
$wildcard = Join-Path (Get-Location) "PowerShell/[D]eleteFiles.ps1"
$literal = Join-Path (Get-Location) "PowerShell/DeleteFiles.ps1"
Write-Output "--- -Path wildcard probe ---"
Remove-Item -Path $wildcard -Force -WhatIf -ErrorAction Continue
Write-Output "--- -LiteralPath wildcard probe ---"
Remove-Item -LiteralPath $wildcard -Force -WhatIf -ErrorAction Continue
Write-Output "--- exact path probe ---"
Remove-Item -Path $literal -Force -WhatIf -ErrorAction Continue
'Repository: terjeinnerdal/scripts
Length of output: 743
Use -LiteralPath for deletion.
Remove-Item -Path interprets wildcard characters in $file.FullName. Use Remove-Item -LiteralPath $file.FullName -Force to target only the selected file.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@PowerShell/DeleteFiles.ps1` around lines 52 - 53, Update the Remove-Item
invocation within the ShouldProcess deletion block to use -LiteralPath instead
of -Path with $file.FullName, ensuring wildcard characters are treated literally
and only the selected file is deleted.
Source: Coding guidelines
| if ($PSCmdlet.ShouldProcess($file.FullName, "Delete file")) { | ||
| Remove-Item -Path $file.FullName -Force | ||
| Write-Host "Deleted: $($file.FullName)" -ForegroundColor Green |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/sh
set -eu
printf '%s\n' '--- file list ---'
git ls-files 'PowerShell/DeleteFiles.ps1'
printf '%s\n' '--- relevant source ---'
cat -n PowerShell/DeleteFiles.ps1 | sed -n '1,110p'
printf '%s\n' '--- deletion and error handling references ---'
rg -n -C 3 'Remove-Item|ErrorAction|try|catch|ShouldProcess|Write-Host' PowerShell/DeleteFiles.ps1Repository: terjeinnerdal/scripts
Length of output: 2986
🏁 Script executed:
#!/bin/sh
set -eu
if command -v pwsh >/dev/null 2>&1; then
PS= pwsh
elif command -v powershell >/dev/null 2>&1; then
PS= powershell
else
printf '%s\n' 'No PowerShell executable is available in the sandbox.'
exit 0
fi
"$PS" -NoProfile -NonInteractive -Command '
$Error.Clear()
Remove-Item -Path "/path/that/does/not/exist/coderabbit-probe" -Force
Write-Output ("success-message-reached; error-count=" + $Error.Count + "; last-success=" + $?)
'Repository: terjeinnerdal/scripts
Length of output: 868
Stop on Remove-Item failure before reporting deletion
Remove-Item continues after a non-terminating error. The script can report Deleted when removal fails. Add -ErrorAction Stop or handle the failure before writing the success message.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@PowerShell/DeleteFiles.ps1` around lines 52 - 54, Update the Remove-Item call
within the ShouldProcess block to use terminating error behavior, such as
ErrorAction Stop, so failures prevent execution from reaching the Write-Host
success message. Keep the existing deletion and success-reporting flow unchanged
for successful removals.
| ## 🛠️ Repository Overview | ||
|
|
||
| ### NordVPN | ||
| ``` |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add a language to the repository-tree code fence.
markdownlint-cli2 reports MD040 for this fence. Use text because the block contains a directory tree.
Proposed fix
-```
+```text📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ``` |
🧰 Tools
🪛 markdownlint-cli2 (0.23.2)
[warning] 9-9: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@README.md` at line 9, Update the repository-tree fenced code block in the
README to specify the text language, changing the unlabeled fence to a
text-labeled fence so markdownlint MD040 passes.
Source: Linters/SAST tools
| # Delete empty subdirectories safely with confirmation | ||
| .\PowerShell\ManageEmptyFolders.ps1 -Path "C:\Data" -Delete | ||
|
|
||
| # Dry-run deletion using -WhatIf | ||
| .\PowerShell\ManageEmptyFolders.ps1 -Path "C:\Data" -Delete -WhatIf |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- README excerpt ---'
sed -n '70,100p' README.md
printf '%s\n' '--- candidate script files ---'
fd -i 'ManageEmptyFolders.ps1' .
printf '%s\n' '--- parameter and deletion logic ---'
script="$(fd -i -t f 'ManageEmptyFolders.ps1' . | head -n 1)"
if [ -n "$script" ]; then
rg -n -C 4 'param|Confirm|WhatIf|ShouldProcess|Delete|Remove-Item|SupportsShouldProcess|ConfirmImpact' "$script"
fi
printf '%s\n' '--- related documentation references ---'
rg -n -i -C 3 'ManageEmptyFolders|WhatIf|Confirm|confirmation|empty subdirector' README.md PowerShell 2>/dev/null || trueRepository: terjeinnerdal/scripts
Length of output: 10569
🌐 Web query:
PowerShell SupportsShouldProcess ConfirmImpact default ConfirmPreference default -Confirm automatic confirmation behavior
💡 Result:
In PowerShell, the automatic confirmation behavior is governed by the interaction between the ConfirmImpact of a command and the $ConfirmPreference preference variable [1][2]. The default values are: - $ConfirmPreference: High [2][3][4] - ConfirmImpact (for a function using [CmdletBinding(SupportsShouldProcess)] without an explicit ConfirmImpact specified): Medium [1][5] Automatic confirmation behavior: PowerShell automatically prompts the user for confirmation when a command's assigned ConfirmImpact level is equal to or greater than the current value of the $ConfirmPreference variable [2][6]. Because the default $ConfirmPreference is High and the default ConfirmImpact for a function supporting ShouldProcess is Medium, functions with the default impact do not prompt the user for confirmation by default [1][5][6]. To trigger an automatic confirmation prompt for such a function, you must either explicitly set the function's ConfirmImpact to High or lower the user's $ConfirmPreference to Medium or Low [1][5]. If the $ConfirmPreference variable is set to None, PowerShell will never automatically prompt for confirmation, regardless of the command's ConfirmImpact [2]. Users can always override this behavior for a single command by using the -Confirm or -Confirm:$false parameters [2].
Citations:
- 1: https://learn.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-shouldprocess?view=powershell-7.6
- 2: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.6
- 3: https://devblogs.microsoft.com/powershell/confirmpreference/
- 4: https://www.tpointtech.com/powershell-preference-variables
- 5: https://vexx32.github.io/2018/11/22/Implementing-ShouldProcess/
- 6: https://4sysops.com/archives/confirm-confirmpreference-and-confirmimpact-in-powershell/
Add -Confirm to the destructive example.
-Delete does not prompt by default because the script uses the default ConfirmImpact of Medium, while $ConfirmPreference defaults to High. Add -Confirm, or change the description to state that confirmation requires the -Confirm switch.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@README.md` around lines 86 - 90, Update the destructive
ManageEmptyFolders.ps1 README example to include the -Confirm switch with
-Delete, and update the dry-run example if needed to keep the documented command
behavior consistent.
|
|
||
| ## 🤖 Code Quality & CI | ||
|
|
||
| This repository uses [GitHub Actions](file:///.github/workflows/lint.yml) to ensure code quality on every push and pull request: |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use a repository-relative workflow link.
file:///.github/workflows/lint.yml is a local file URI. It does not point to the repository file on GitHub. Use a relative link.
Proposed fix
-This repository uses [GitHub Actions](file:///.github/workflows/lint.yml) to ensure code quality on every push and pull request:
+This repository uses [GitHub Actions](./.github/workflows/lint.yml) to ensure code quality on every push and pull request:📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| This repository uses [GitHub Actions](file:///.github/workflows/lint.yml) to ensure code quality on every push and pull request: | |
| This repository uses [GitHub Actions](./.github/workflows/lint.yml) to ensure code quality on every push and pull request: |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@README.md` at line 105, Update the GitHub Actions link in the README to use
the repository-relative path .github/workflows/lint.yml instead of the local
file:// URI, preserving the surrounding description.
Summary by CodeRabbit
New Features
Documentation
Quality