Skip to content

Feature/add status sh file - #25

Open
terjeinnerdal wants to merge 7 commits into
mainfrom
feature/add_status_sh_file
Open

Feature/add status sh file#25
terjeinnerdal wants to merge 7 commits into
mainfrom
feature/add_status_sh_file

Conversation

@terjeinnerdal

@terjeinnerdal terjeinnerdal commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added OpenSSL-based file encryption and decryption utilities with secure passphrase handling.
    • Added configurable file cleanup with filtering, age thresholds, recursive scanning, and safe preview/confirmation options.
    • Improved empty-folder management through shared handling and safe operation support.
    • NordVPN utilities now support token-based login and copy peer configuration data when distributing scripts.
  • Documentation

    • Expanded the README with usage examples, supported tools, repository guidance, and quality-check information.
  • Quality

    • Added automated ShellCheck and PowerShell analysis checks.
    • Standardized Bash script launching for improved portability.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4306d36e-3533-4817-9145-1df8d15cada0

📥 Commits

Reviewing files that changed from the base of the PR and between d438a7b and 87e5aef.

📒 Files selected for processing (4)
  • .github/workflows/lint.yml
  • bash/encryption/decrypt_file.sh
  • bash/encryption/encrypt_file.sh
  • bash/nord/login.sh
🚧 Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/lint.yml
  • bash/encryption/decrypt_file.sh
  • bash/encryption/encrypt_file.sh

📝 Walkthrough

Walkthrough

Added 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.

Changes

Encryption utilities

Layer / File(s) Summary
OpenSSL encryption and decryption
bash/encryption/encrypt_file.sh, bash/encryption/decrypt_file.sh
Added AES-256-CBC encryption and decryption with PBKDF2, passphrase validation, output handling, and failure cleanup.

PowerShell cleanup tools

Layer / File(s) Summary
Filtered file deletion
PowerShell/DeleteFiles.ps1
Added file selection by path, filter, age, and recursion. Deletion uses ShouldProcess.
Empty-folder delegation
PowerShell/DeleteEmptyFolders.ps1, PowerShell/FindEmptySubDirectories.ps1, PowerShell/ManageEmptyFolders.ps1
Changed empty-folder scripts to delegate operations to ManageEmptyFolders.ps1 and updated its examples.

Bash portability and Meshnet scripts

Layer / File(s) Summary
Portable Bash execution
bash/AutoRemoveSnapd.sh, bash/countLines.sh, bash/nord/*
Standardized Bash shebangs. Added peers.json copying and quoted peer-list filter arguments.
NordVPN token login
bash/nord/login.sh
Replaced the hardcoded token with argument, environment-variable, or interactive token input.

Repository quality checks and documentation

Layer / File(s) Summary
Lint workflow and repository guide
.github/workflows/lint.yml, README.md
Added ShellCheck and PSScriptAnalyzer workflow jobs. Expanded repository usage and structure 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
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title refers to adding a status shell file, but the changes add linting, encryption, cleanup, and NordVPN script updates instead. Use a title that identifies the main change, such as "Add repository lint workflow and improve utility scripts".
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/add_status_sh_file

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 20

🧹 Nitpick comments (3)
.github/workflows/lint.yml (1)

16-16: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Pin 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 win

Complete 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 lift

Extract the implementation from this top-level script.

This file contains parameter handling, file selection, and deletion. Move the reusable logic into a *.Function.ps1 function. Keep PowerShell/DeleteFiles.ps1 as the CLI wrapper and preserve its ShouldProcess behavior.

As per coding guidelines, PowerShell/!(*.Function).ps1 scripts 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

📥 Commits

Reviewing files that changed from the base of the PR and between 30703f1 and d438a7b.

📒 Files selected for processing (22)
  • .github/workflows/lint.yml
  • PowerShell/DeleteEmptyFolders.ps1
  • PowerShell/DeleteFiles.ps1
  • PowerShell/FindEmptySubDirectories.ps1
  • PowerShell/FindEmptySubDirectories.txt
  • PowerShell/ManageEmptyFolders.ps1
  • PowerShell/ManageEmptyFolders2.ps1
  • README.md
  • bash/AutoRemoveSnapd.sh
  • bash/countLines.sh
  • bash/encryption/decrypt_file.sh
  • bash/encryption/encrypt_file.sh
  • bash/nord/config.sh
  • bash/nord/connect.sh
  • bash/nord/copy_scripts.sh
  • bash/nord/exit_node.sh
  • bash/nord/list_peers.sh
  • bash/nord/login.sh
  • bash/nord/logout.sh
  • bash/nord/nord_watchdog.sh
  • bash/nord/reset.sh
  • bash/nord/set_nickname.sh
💤 Files with no reviewable changes (2)
  • PowerShell/ManageEmptyFolders2.ps1
  • PowerShell/FindEmptySubDirectories.txt

Comment on lines +1 to +3
name: Lint Scripts

on:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 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 -250

Repository: 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:


🌐 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:


🏁 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}' || true

Repository: 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

Comment on lines +3 to +7
on:
push:
branches: [ main, master, "feature/**" ]
pull_request:
branches: [ main, master ]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Comment thread .github/workflows/lint.yml
Comment on lines +1 to +2
#!/usr/bin/env bash
set -euo pipefail

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 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: add umask 077 before the encryption output is created.
  • bash/encryption/decrypt_file.sh#L1-L2: add umask 077 before 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.

Comment on lines +4 to +12
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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 -h and --help.
  • bash/encryption/decrypt_file.sh#L4-L12: accept exactly one or two arguments and return 0 for -h and --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.

Comment on lines +52 to +53
if ($PSCmdlet.ShouldProcess($file.FullName, "Delete file")) {
Remove-Item -Path $file.FullName -Force

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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 || true

Repository: 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)")
PY

Repository: 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

Comment on lines +52 to +54
if ($PSCmdlet.ShouldProcess($file.FullName, "Delete file")) {
Remove-Item -Path $file.FullName -Force
Write-Host "Deleted: $($file.FullName)" -ForegroundColor Green

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.ps1

Repository: 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.

Comment thread README.md
## 🛠️ Repository Overview

### NordVPN
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.

Suggested change
```
🧰 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

Comment thread README.md
Comment on lines +86 to +90
# 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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 || true

Repository: 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:


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.

Comment thread README.md

## 🤖 Code Quality & CI

This repository uses [GitHub Actions](file:///.github/workflows/lint.yml) to ensure code quality on every push and pull request:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.

Suggested change
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.

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.

1 participant