OWASP / OWASP/Nettacker

Resource Leaks: Files not closed properly in multiple modules

Open
#1,320 0 comments 0 reactions 1 assignee View on GitHub

@Tech-Psycho95 is already working on this.

Since Mar 2, 2026.

  • #1387 by @Tech-Psycho95 — open
Dominant language
Python
Stars
5.6k
Forks
1.2k
Avg merge
1d 21h
Merged PRs (30d)
16

Description

Summary

Some Nettacker modules use open().read() without context managers, which can leave file handles open and cause resource leaks. This can lead to exhaustion of file descriptors in long‑running processes.

Problem

The following module contain unsafe file reads:

File Fix Applied
nettacker/lib/html_log/log_data.py HTML template reads
nettacker/lib/graph/d3_tree_v1/engine.py D3 tree template read
nettacker/lib/compare_report/engine.py Compare report template read
Resolution

Replace all bare open() calls with context managers:

# Before (unsafe)
content = open(filename).read()

# After (safe)
with open(filename) as f:
    content = f.read()
Testing
  • Add new pytest tests under tests/lib/ to confirm:

  • Files are read correctly.

  • File handles are closed after reading.

  • Edge cases (empty file, missing file) are handled properly.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.