Skip to content

Created recursive script for *nix systems#23

Open
jamsajones wants to merge 17 commits intotheNetworkChuck:mainfrom
jamsajones:main
Open

Created recursive script for *nix systems#23
jamsajones wants to merge 17 commits intotheNetworkChuck:mainfrom
jamsajones:main

Conversation

@jamsajones
Copy link
Copy Markdown

@jamsajones jamsajones commented Apr 1, 2026

Summary

Implemented a recursive version of the script to it will look through my home directory for all projects that have a package.json file. It then uses @cristianchies dependency scanning tree solution (#6 ) to find if any deps of that project contain axios. It also incorporates @Bassonrichard's PR (#8 )to ensure that all projects are found regardless of the package manager (attribution was maintained). PR #1 was pulled in for good measure.

Note: I do not have a Windows instance to test on, so check.ps1 (and the PowerShell lockfile changes from PR #8) are untested on Windows. The logic mirrors the bash version and looks correct, but if anyone with a Windows machine can verify, that would be appreciated. Sorry about that!

Note: I have a windows recursive version but PR #5 looks to be a better solution and I cannot test windows.

jamsajones and others added 10 commits April 1, 2026 15:03
This script is a copy of the check.sh file to recursively find and scan all JS projects.
…sh to avoid false positives and check all versions in dependency tree
Scan yarn.lock, pnpm-lock.yaml, and deno.lock alongside package-lock.json.
For bun.lockb (binary format), decode via `bun bun.lockb` when available
and warn if bun is not installed rather than silently skipping.
Also extend git history forensic scan to cover all lockfile types.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previously, the version regex (1.14.1|0.30.4) was matched across the
entire lockfile, flagging any package that happened to share those
version numbers. For example, dashdash@1.14.1 — a completely unrelated
argument parsing library — would trigger a false AFFECTED result.

Lockfile checks are now scoped to axios entries only:
- package-lock.json: searches within the "node_modules/axios" block
- yarn.lock / bun (decoded): uses awk to find blocks whose header
  starts with "axios@" before checking the resolved version field
- pnpm-lock.yaml: matches "/axios@VERSION:" key format explicitly
- deno.lock: matches "axios@VERSION" JSON key format explicitly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
In check.ps1, $lockHit was not reset before the package-lock.json block,
meaning a truthy value from a prior run could carry over and trigger a
false positive. Fixed by initialising $lockHit = $null at the top of
each block.

Also corrected the LineNumber offset: Select-String returns 1-based line
numbers but PowerShell arrays are 0-indexed, so the block slice now uses
($axiosIdx - 1) to avoid skipping the matched line. Bumped the slice
window from +3 to +4 lines to match the -A 5 depth used in check.sh.

In check.sh, bumped grep -A 3 to -A 5 so the version field is captured
in npm lockfile v1/v2 where it may sit deeper in the block.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jamsajones jamsajones changed the title Merge community PRs #1, #6, #8 with attribution Created recursive script for *nix systems Apr 1, 2026
@jamsajones jamsajones marked this pull request as draft April 1, 2026 22:57
@jamsajones jamsajones marked this pull request as draft April 1, 2026 22:57
jamsajones and others added 7 commits April 1, 2026 16:03
Shows a live counter while find is scanning so the user knows the script
is still running on large directory trees.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extends the dep tree scan (from PR theNetworkChuck#6's npm list --all) to yarn, pnpm,
and bun across all four scripts: check.sh, check.ps1, check-revursive.sh,
and check-recursive.ps1.

- npm: npm list axios --all
- yarn: yarn why axios
- pnpm: pnpm list axios --depth=Infinity
- bun: bun pm ls --all

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove sort -u pipe which buffered all output until find completed.
Deduplicate in-loop with an associative array instead, so the counter
updates in real time as projects are found.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Show a spinning animation while find runs in the background so the user
knows the script is working. Default scan root changed from $HOME to
current working directory. Bash 3.2 compatible (no associative arrays).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Skip .bun, .yarn, .pnpm, .pnpm-store, .npm, .cache, Cache, and Caches
directories to avoid false positives from cached package metadata.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document the recursive detection script usage and note that it scans
the current directory by default.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jamsajones jamsajones marked this pull request as ready for review April 2, 2026 00:29
@DenisLantero
Copy link
Copy Markdown

I have a concern about how bun.lockb is handled in these scripts.

It looks like the scripts decode it by running bun bun.lockb. That means we’re invoking the Bun CLI on repository-controlled content, rather than using a passive parser.

Could we test what happens if a repository contains a malicious or non-standard bun.lockb file (e.g. a plain text file or intentionally malformed content)? I’m not sure whether bun strictly parses it as a lockfile or if there are edge cases where this could lead to unintended execution or other unsafe behavior.

If there is any ambiguity here, it might be safer to either:

  • avoid invoking bun on untrusted bun.lockb files
  • explicitly validate the file before processing it
  • fall back to a non-executing parser if one exists.

Just want to make sure we’re not implicitly trusting input that comes from repos.

@jamsajones
Copy link
Copy Markdown
Author

@DenisLantero thanks for the feedback.

avoid invoking bun on untrusted bun.lockb files

  • What does trust mean for a bun.lockb?
  • What would validate it if it besides the bun executable?
  • If this is on your machine and there is a node_modules folder wouldn't that indicate that bun has already parsed and exec'd this bun.lockb?

Happy to work on this more and solve the issue but I am no bun expert and so I don't fully understand the issue that you are addressing here. Will take me some time to research and fix without more info (2:35a here on the west coast of the us).

I would also be happy to merge anything you think needs to change into this repo with a PR.

@jamsajones
Copy link
Copy Markdown
Author

jamsajones commented Apr 2, 2026

@DenisLantero

FWIW, this was a great effort by @theNetworkChuck to help scan for this very quickly. THANKS @theNetworkChuck!

Considering that I am not a security professional (although we all have to wear that hat and try) and I don't know what the long term intent is of @theNetworkChuck for this project, if this solution only works for me so be it... no ego here.

So, if you have a better solution please take over my work (pull my code into your own version of this) or replace it and I will close the PR. The important thing is that the community has a safe, reliable, and fast answer to know if they were impacted, and that is all that matters to me.

¯\_(ツ)_/¯

@DenisLantero
Copy link
Copy Markdown

@DenisLantero thanks for the feedback.

avoid invoking bun on untrusted bun.lockb files

  • What does trust mean for a bun.lockb?
  • What would validate it if it besides the bun executable?
  • If this is on your machine and there is a node_modules folder wouldn't that indicate that bun has already parsed and exec'd this bun.lockb?

Happy to work on this more and solve the issue but I am no bun expert and so I don't fully understand the issue that you are addressing here. Will take me some time to research and fix without more info (2:35a here on the west coast of the us).

I would also be happy to merge anything you think needs to change into this repo with a PR.

Thanks, that makes sense, I think I can clarify my concern better.

I’m not saying this is definitely an exploitable issue, just something that might be worth double checking.

The scenario I have in mind is this:

  • a user runs this script locally (possibly even from root) across multiple repos on their machine (like I did lol)
  • one of those repos is untrusted or malicious
  • that repo contains a malformed or unexpected bun.lockb
  • the script runs bun bun.lockb, effectively passing that file to bun

Even if bun intends to treat bun.lockb as a lockfile, I’m not fully sure how it behaves with malformed or non standard files, so I just wanted to question whether we’re implicitly trusting that behavior.

I don’t have proof that this leads to code execution or anything like that , just pointing out that we are invoking a CLI on content that might be malicious.

Since this is a local script, a simple "fix" could be something like adding a warning "If you have untrusted repositories on your machine, you may want to skip scanning bun.lockb files", or something along these lines, a simple prompt to the user asking if he wants do disable checking bun.lockd files (if the issue I pointed out actually is a vulnerabilty) might be enough.

@DenisLantero
Copy link
Copy Markdown

@DenisLantero

FWIW, this was a great effort by @theNetworkChuck to help scan for this very quickly. THANKS @theNetworkChuck!

Considering that I am not a security professional (although we all have to wear that hat and try) and I don't know what the long term intent is of @theNetworkChuck for this project, if this solution only works for me so be it... no ego here.

So, if you have a better solution please take over my work (pull my code into your own version of this) or replace it and I will close the PR. The important thing is that the community has a safe, reliable, and fast answer to know if they were impacted, and that is all that matters to me.

¯_(ツ)_/¯

You did a great job, I prefer your approach to this script since it is more complete and it has a broader scope.

The issue I pointed out is only a remote possibility, since users might think "Let me run this on my root to check my whole machine" (like I did) and might have unsafe code cloned, a simple way to turn the bun check on / off might be a good feature (even a y/n prompt).

If you can implement this it would be great, otherwise I'd be happy to open a PR if needed!

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.

5 participants