OWASP / OWASP/cve-lite-cli

test: add coverage for phantom-utils (getDeclaredPackages and installCmd)

Open Beginner friendly
#1,088 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

first-timers-only good first issue help wanted
Dominant language
TypeScript
Stars
715
Forks
145
Avg merge
21h 39m
Merged PRs (30d)
66

Description

This issue is reserved for first-time contributors. If you have contributed to open source before, please leave it for someone who has not. There are other issues labelled good first issue that are not reserved.

The task

src/overrides/detectors/phantom-utils.ts has two small functions and no tests. Both are pure, so no mocking or setup is needed.

What the functions do

getDeclaredPackages(packageJson) collects every dependency name declared across dependencies, devDependencies, peerDependencies and optionalDependencies, and returns them as a Set.

installCmd(packageManager) maps a package manager to its install command: pnpm gives pnpm add, yarn gives yarn add, bun gives bun add, and anything else gives npm install.

Steps

  1. Comment here saying you would like to take it, so nobody duplicates your work.
  2. Fork the repo and create a branch, for example test/phantom-utils-coverage.
  3. Run npm install then npm test to confirm a clean starting point.
  4. Create tests/overrides/phantom-utils.test.ts. Look at any file in tests/ for the house style; the imports use a .js extension even though the files are TypeScript, which is expected.
  5. Write the tests. Suggested cases:
    • collects names from all four dependency sections
    • returns an empty set for an empty package.json
    • ignores a section that is an array rather than an object
    • ignores a section that is null
    • deduplicates a package that appears in two sections
    • returns the right command for each of pnpm, yarn, bun, npm
  6. Run npm test and confirm everything passes.
  7. Open a pull request with Closes #NNN in the body, using this issue's number.

Tips

Prefer one behaviour per test with a name that says what the behaviour is. it("deduplicates a package declared in two sections") is better than it("works").

Ask questions here if anything is unclear. A question is not a bother, and getting stuck is normal.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading src/overrides/detectors/phantom-utils.ts and a nearby file in tests/ for the house style. Run npm install and npm test, then add tests/overrides/phantom-utils.test.ts covering the listed dependency-section and package-manager cases. Done means the new tests pass with npm test and the pull request references this issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
testing-qa
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
92/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.