
njsscan是一款静态应用安全测试(SAST)工具,专为Node.js应用设计。它结合了https://github.com/ajinabraham/libsast%E7%9A%84%E7%AE%80%E5%8D%95%E6%A8%A1%E5%BC%8F%E5%8C%B9%E9%85%8D%E5%99%A8%E5%92%8Chttps://github.com/returntocorp/semgrep%E7%9A%84%E8%AF%AD%E6%B3%95%E6%84%9F%E7%9F%A5%E8%AF%AD%E4%B9%89%E4%BB%A3%E7%A0%81%E6%A8%A1%E5%BC%8F%E6%90%9C%E7%B4%A2%E8%83%BD%E5%8A%9B%EF%BC%8C%E8%83%BD%E5%A4%9F%E6%9C%89%E6%95%88%E8%AF%86%E5%88%ABNode.js%E6%BA%90%E4%BB%A3%E7%A0%81%E4%B8%AD%E7%9A%84%E4%B8%8D%E5%AE%89%E5%85%A8%E4%BB%A3%E7%A0%81%E6%A8%A1%E5%BC%8F%E3%80%82
.njsscan配置文件自定义扫描规则、忽略路径和文件pip install njsscanbash$ njsscan usage: njsscan [-h] [--json] [--sarif] [--sonarqube] [--html] [-o OUTPUT] [-c CONFIG] [--missing-controls] [-w] [-v] [path ...] 位置参数: path 源代码文件或目录路径 可选参数: -h, --help 显示帮助信息并退出 --json 设置输出格式为JSON --sarif 设置输出格式为SARIF 2.1.0 --sonarqube 设置为SonarQube兼容格式 --html 设置输出格式为HTML -o OUTPUT, --output OUTPUT 保存结果的输出文件名 -c CONFIG, --config CONFIG .njsscan配置文件位置 --missing-controls 启用缺失安全控制检查 -w, --exit-warning 警告时返回非零退出码 -v, --version 显示njsscan版本
基本扫描命令:
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>") │ │ │ │ ╘════════════════╧═══════════════════════════════════════════════╛ │ ╘═════════════╧═══════════════════════════════════════════════════════════════════════════════════════════════╛
通过项目根目录的.njsscan文件或--config参数指定的配置文件自定义扫描行为:
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
在触发问题的代码行添加注释 // njsscan-ignore: rule_id1, rule_id2 可忽略指定规则:
javascriptapp.get('/some/redirect', function (req, res) { var target = req.param("target"); res.redirect(target); // njsscan-ignore: express_open_redirect });
bashdocker pull opensecurity/njsscan docker run -v /本地源代码路径:/src opensecurity/njsscan /src
bashdocker build -t njsscan . docker run -v /本地源代码路径:/src njsscan /src
创建文件 .github/workflows/njsscan.yml:
yamlname: 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@v2 - name: nodejsscan scan id: njsscan uses: ajinabraham/njsscan-action@master with: args: '.'
在 .gitlab-ci.yml 中添加:
yamlstages: - test njsscan: image: python before_script: - pip3 install --upgrade njsscan script: - njsscan .
在 .travis.yml 中添加:
yamllanguage: python install: - pip3 install --upgrade njsscan script: - njsscan .
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': [] }
nodejsscan基于njsscan构建,提供完整的漏洞管理用户界面及其他集成功能。详情参见https://github.com/ajinabraham/nodejsscan%E3%80%82
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。



探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务