Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

订阅源联系隐私© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
njsscan — 面向Node.js应用的语义感知SAST扫描器,利用libsast模式匹配和semgrep语法感知分析,检测不安全代码模式。 | Kitploit
工具/GitHubGitHub/ajinabraham/njsscan
静态分析漏洞扫描器静态代码分析 (SAST)代码分析Web安全DevSecOps代码分析 分类第 13 名静态代码分析 (SAST) 分类第 10 名
GitHubajinabraham/njsscan

njsscan

43610812828天前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

面向Node.js应用的语义感知SAST扫描器,利用libsast模式匹配和semgrep语法感知分析,检测不安全代码模式。

查看仓库网站
# njsscan
**njsscan** 是一款静态应用程序测试(SAST)工具,它使用来自 [libsast](https://github.com/ajinabraham/libsast) 的简单模式匹配器以及语法感知的语义代码模式搜索工具 [semgrep](https://github.com/returntocorp/semgrep),在您的 node.js 应用程序中查找不安全的代码模式。

在印度用 ![Love](https://assets.kitploit.com/production/public/readmes/5043/b3821ff3e9618f0eddb3e737339f0573d7ab0a2e4a3d0fdccf80925bdd5cf319.png) 制作  [![Tweet](https://img.shields.io/twitter/url?url=https://github.com/ajinabraham/njsscan)](https://twitter.com/intent/tweet/?text=njsscan%20is%20a%20semantic%20aware%20SAST%20tool%20that%20can%20find%20insecure%20code%20patterns%20in%20your%20Node.js%20applications%20by%20%40ajinabraham%20%40OpenSecurity_IN&url=https://github.com/ajinabraham/njsscan)

[![PyPI version](https://badge.fury.io/py/njsscan.svg)](https://badge.fury.io/py/njsscan)
[![platform](https://img.shields.io/badge/platform-osx/linux-green.svg)](https://github.com/ajinabraham/njsscan)
[![License](https://img.shields.io/:license-lgpl3+-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0.en.html)
[![python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![Build](https://github.com/ajinabraham/njsscan/workflows/Build/badge.svg)](https://github.com/ajinabraham/njsscan/actions?query=workflow%3ABuild)

### 支持 njsscan

* **通过 Paypal 捐赠:** [![Donate via Paypal](https://assets.kitploit.com/production/public/readmes/5043/154f3a9ed4f3ac0059fc18337f3cb4d28103f349b3e256458f6a39b23d3c092b.gif)](https://paypal.me/ajinabraham)
* **赞助本项目:** [![Github Sponsors](https://assets.kitploit.com/production/public/readmes/5043/2ec01911ba34e48906cabcf91fef477ed314b36a2a1340b226976e3b8c7f271f.png)](https://github.com/sponsors/ajinabraham)

### 在线学习课程与认证
[![OpSecX Video Course](https://assets.kitploit.com/production/public/readmes/5043/870da208b8fa80e7000c8585cbbb345057dfa18c657a493215eab4517c60876f.png)](https://opsecx.com/index.php/product/node-js-security-pentesting-and-exploitation/?uid=github) [OpSecX Node.js Security: Pentesting and Exploitation - NJS](https://opsecx.com/index.php/product/node-js-security-pentesting-and-exploitation/?uid=github)

## 安装

`pip install njsscan`

需要 Python 3.10+,仅支持 Mac 和 Linux

## 命令行选项

```bash
$ njsscan
usage: njsscan [-h] [--json] [--sarif] [--sonarqube] [--defectdojo] [--gitlab-sast] [--html] [-o OUTPUT] [-c CONFIG] [--missing-controls] [-w] [-v] [path ...]

positional arguments:
  path                  Path can be file(s) or directories with source code

optional arguments:
  -h, --help            show this help message and exit
  --json                set output format as JSON
  --sarif               set output format as SARIF 2.1.0
  --sonarqube           set output format compatible with SonarQube
  --defectdojo          set output format compatible with DefectDojo Generic Findings Import
  --gitlab-sast         set output format as GitLab SAST report
  --html                set output format as HTML
  -o OUTPUT, --output OUTPUT
                        output filename to save the result
  -c CONFIG, --config CONFIG
                        Location to .njsscan config file
  --missing-controls    enable missing security controls check
  -w, --exit-warning    non zero exit code on warning
  -v, --version         show njsscan version
```


## 使用示例

```bash
$ njsscan test.js
- Pattern Match ████████████████████████████████████████████████████████████ 1
- Semantic Grep ███████████████████████████ 160

njsscan: v0.1.9 | Ajin Abraham | opensecurity.in
╒═════════════╤═══════════════════════════════════════════════════════════════════════════════════════════════╕
│ RULE ID     │ express_xss                                                                                   │
├─────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤
│ OWASP       │ A1: Injection                                                                                 │
├─────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤
│ CWE         │ CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')  │
├─────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤
│ DESCRIPTION │ Untrusted User Input in Response will result in Reflected Cross Site Scripting Vulnerability. │
├─────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤
│ SEVERITY    │ ERROR                                                                                         │
├─────────────┼───────────────────────────────────────────────────────────────────────────────────────────────┤
│ FILES       │ ╒════════════════╤═══════════════════════════════════════════════╕                            │
│             │ │ File           │ test.js                                       │                            │
│             │ ├────────────────┼───────────────────────────────────────────────┤                            │
│             │ │ Match Position │ 5 - 46                                        │                            │
│             │ ├────────────────┼───────────────────────────────────────────────┤                            │
│             │ │ Line Number(s) │ 7: 8                                          │                            │
│             │ ├────────────────┼───────────────────────────────────────────────┤                            │
│             │ │ Match String   │ const { name } = req.query;                   │                            │
│             │ │                │     res.send('<h1> Hello :' + name + "</h1>") │                            │
│             │ ╘════════════════╧═══════════════════════════════════════════════╛                            │
╘═════════════╧═══════════════════════════════════════════════════════════════════════════════════════════════╛
```

## nodejsscan SAST

**nodejsscan** 构建于 **njsscan** 之上,提供了一套完整的漏洞管理用户界面以及其他实用的集成功能。

![nodejsscan web ui](https://assets.kitploit.com/production/public/readmes/5043/84d1df3bcde830f024b97f4a79839ed0aac6f3ff5543af66d8df0f165e490bc3.png)

参见 [nodejsscan](https://github.com/ajinabraham/nodejsscan)

## Python API

```python
>>> from njsscan.njsscan import NJSScan
>>> node_source = '/node_source/true_positives/sqli_node.js'
>>> scanner = NJSScan([node_source], json=True, check_controls=False)
>>> scanner.scan()
{
    'templates': {},
    'nodejs': {
        'node_sqli_injection': {
            'files': [{
                'file_path': '/node_source/true_positives/sqli_node.js',
                'match_position': (1, 24),
                'match_lines': (4, 11),
                'match_string': 'var employeeId = req.foo;\n\nvar sql = "SELECT * FROM trn_employee WHERE employee_id = " + employeeId;\n\n\n\nconnection.query(sql, function (error, results, fields) {\n\n    if (error) {\n\n        throw error;\n\n    }\n\n    console.log(results);'
            }],
            'metadata': {
                'owasp': 'A1: Injection',
                'cwe': "CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')",
                'description': 'Untrusted input concatinated with raw SQL query can result in SQL Injection.',
                'severity': 'ERROR'
            }
        }
    },
    'errors': []
}
```

## 配置 njsscan

源代码目录根部的 `.njsscan` 文件允许您配置 njsscan。您也可以使用 `--config` 参数指定自定义的 `.njsscan` 文件。

```yaml
---
- nodejs-extensions:
  - .js

  template-extensions:
  - .new
  - .hbs
  - ''

  ignore-filenames:
  - skip.js

  ignore-paths:
  - __MACOSX
  - skip_dir
  - node_modules

  ignore-extensions:
  - .jsx

  ignore-rules:
  - regex_injection_dos
  - pug_jade_template

  severity-filter:
  - WARNING
  - ERROR

  severity-overrides:
    express_xss: WARNING
    node_secret: ERROR
```

## 抑制发现结果

您可以通过在触发发现结果的行上添加注释 `// njsscan-ignore: rule_id1, rule_id2` 来抑制 javascript 源文件中的发现结果。

示例:

```javascript
app.get('/some/redirect', function (req, res) {
    var target = req.param("target");
    res.redirect(target); // njsscan-ignore: express_open_redirect
});
```

## CI/CD 集成

您可以在 CI/CD 或 DevSecOps 流水线中启用 njsscan。

#### Github Action

将以下内容添加到文件 `.github/workflows/njsscan.yml` 中。

```yaml
name: njsscan
on:
  push:
    branches: [ master, main ]
  pull_request:
    branches: [ master, main ]
jobs:
  njsscan:
    runs-on: ubuntu-latest
    name: njsscan check
    steps:
    - name: Checkout the code
      uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
    - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
      with:
        python-version: '3.12'
    - name: nodejsscan scan
      id: njsscan
      uses: ajinabraham/njsscan-action@231750a435d85095d33be7d192d52ec650625146 # v9
      with:
        args: '.'
```
示例:[dvna with njsscan github action](https://github.com/ajinabraham/dvna/actions?query=workflow%3Anjsscan)

#### Github 代码扫描集成

将以下内容添加到文件 `.github/workflows/njsscan_sarif.yml` 中。

```yaml
name: njsscan sarif
on:
  push:
    branches: [ master, main ]
  pull_request:
    branches: [ master, main ]
jobs:
  njsscan:
    runs-on: ubuntu-latest
    name: njsscan code scanning
    steps:
    - name: Checkout the code
      uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
    - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
      with:
        python-version: '3.12'
    - name: nodejsscan scan
      id: njsscan
      uses: ajinabraham/njsscan-action@231750a435d85095d33be7d192d52ec650625146 # v9
      with:
        args: '. --sarif --output results.sarif || true'
    - name: Upload njsscan report
      uses: github/codeql-action/upload-sarif@1c5b675653bb5c22dbe9b12b556ec555138e09fd # v4.38.1
      with:
        sarif_file: results.sarif
```
![nodejsscan web ui](https://assets.kitploit.com/production/public/readmes/5043/695ed493409d9398ac3741ad717a34df0109b958ee803083f29b843c58ab96b5.png)


#### Gitlab CI/CD

将以下内容添加到文件 `.gitlab-ci.yml` 中。

```yaml
stages:
  - test

njsscan:
  image: python:3.12
  stage: test
  before_script:
    - pip3 install --upgrade njsscan
  script:
    - njsscan . --gitlab-sast -o gl-sast-report.json
  artifacts:
    when: always
    reports:
      sast: gl-sast-report.json
```

示例命令(本地):

```bash
njsscan . --gitlab-sast -o gl-sast-report.json
```

这会生成原生的 [GitLab SAST 报告](https://docs.gitlab.com/user/application_security/sast/),使发现结果无需 SARIF 转换器即可显示在漏洞报告 / MR 安全小组件中。

示例:[dvna with njsscan gitlab](https://gitlab.com/ajinabraham/dvna/-/jobs/602110439)


#### Travis CI

将以下内容添加到文件 `.travis.yml` 中。

```yaml
language: python
install:
    - pip3 install --upgrade njsscan
script:
    - njsscan .
```

#### Circle CI

将以下内容添加到文件 `.circleci/config.yaml` 中

```yaml
version: 2.1
jobs:
  njsscan:
    docker:
      - image: cimg/python:3.9.6
    steps:
      - checkout
      - run:
          name: Install njsscan
          command: pip install --upgrade njsscan
      - run:
           name: njsscan check
           command: njsscan .
```

## Docker

### 来自 [DockerHub](https://hub.docker.com/r/opensecurity/njsscan) 的预构建镜像

```bash
docker pull opensecurity/njsscan
docker run -v /path-to-source-dir:/src opensecurity/njsscan /src
```

### 本地构建

```
docker build -t njsscan .
docker run -v /path-to-source-dir:/src njsscan /src
```
下载工具