NodeSecure / NodeSecure/js-x-ray

implementing "unclosed-ressource" warning

Open
#692 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
287
Forks
43
Avg merge
16h 34m
Merged PRs (30d)
19

Description

The goal would be to implement a new probe that detect unclosed ressource for example:

const fs = require('fs/promises');

let fileHandle;
try {
  fileHandle = await fs.open('example.txt', 'r');
  // ... perform operations
await fileHandle.close(); // Releases the file resource
} catch(e) {
  console.log(e.message);
 // if an error occurs we don't release the file resource
 throw error;
}
  • A list of modules to cover would be:

File descriptor | (fs) fileHandle.close() / fs.close(fd)
Streams | stream.destroy() or stream.end()
Net/HTTP sockets & servers | socket.destroy(), server.close()
Timers | clearTimeout() / clearInterval(), or timer.unref()
Worker threads | worker.terminate()
DB pool connections | client.release() (library-specific)

  • Edge cases to consider:

Since node 24 we can use Symbol.dispose, Symbol.asyncDispose with the keyword using.

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

The issue names no files, tests, or entry points, so first map the existing probe architecture and how resource lifetimes are represented. Define coverage and completion criteria for file handles, streams, sockets, timers, workers, database connections, and Node 24 disposal syntax before implementing and testing the probe.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
devtools, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.