hard_scaner

0.1.7 • Public • Published

硬编码扫描

pipeline status coverage report

使用

命令行

npm i -g hard_scaner

$ hard_scaner --help

hard_scaner <命令>

命令:
  hard_scaner dir [path]                 扫描目录
  hard_scaner file [path]                扫描文件
  hard_scaner text [language] [content]  扫描文本

Options:
  --version  显示版本号                                                   [布尔]
  --help     显示帮助信息                                                 [布尔]

CI

可以引用Docker镜像hub.byted.org/handsome/hard_scaner:0.1.1,里面预装了hard_scaner命令

举个例子

# .gitlab-ci.yml

image: hub.byted.org/handsome/hard_scaner:0.1.1

test:
  - hard_scaner dir .

本地调试

  1. npm install && npm run build
  2. ./bin/index.js --help

方案

考虑到代码中大部分硬编码的数据类型,都是字符串,所以思路是提取源码中所有的字符串,再用正则匹配出硬编码部分

基于TextMate语法,可以对源码实现标记化,实现提取所有字符串常量。

语言支持

  • [x] Java
  • [x] Objective-C
  • [x] JavaScript / TypeScript
  • [x] Golang
  • [x] Python

新增语法

准备好语法文件(.json/.tmLanguage/.plist),放到grammars文件夹中即可。

也可以提ISSUE。

关于效率

由于域名的规则,与PSM和类名很相似,无法单纯通过正则过滤。

目前会在识别出域名后,dns解析一下,解析成功的判断为域名。但这是一次网络请求,会导致效率较低。

Readme

Keywords

none

Package Sidebar

Install

npm i hard_scaner

Weekly Downloads

1

Version

0.1.7

License

ISC

Unpacked Size

4.72 MB

Total Files

82

Last publish

Collaborators

  • handsome2734