敏感信息扫描
命令功能
用于扫描文件中的敏感信息,如手机号、公网地址、身份证号等,支持用户自定义敏感词。
命令格式
1 | devkit doctor sen-scan {-i INPUT_PATH | --input INPUT_PATH} [-o OUTPUT_PATH | --output OUTPUT_PATH] [-S | --show] [-t [PATH]| --template [PATH]] [-sn {1|2|3|a|b|c}*| --sen-num {1|2|3|a|b|c}*] [-sf PATH| --sen-file PATH] |
参数说明
参数 |
参数选项 |
参数说明 |
---|---|---|
-h/--help |
- |
获取帮助信息。 |
-S/--show |
- |
显示默认敏感词列表。
|
-t/--template |
- |
在指定位置生成敏感词模板,若未指定则默认在doctor目录下生成sen_word.json。可通过-sf指定敏感词模板进行扫描。 |
-sn/--sen-num |
1/2/3/a/b/c |
指定敏感词编号,可通过-S获取敏感词编号,多个以英文逗号分隔,若未指定则默认全部扫描。 |
-sf/--sen-file |
- |
指定自定义敏感词的文件路径,文件格式必须与-t生成的模板文件保持一致。 |
-i/--input |
- |
待扫描的文件夹或文件路径,仅支持扫描文本文件,多个以空格分隔。 |
-o/--output |
- |
扫描报告的存放路径,若未指定则默认在doctor/report/sen_scan目录下生成sen_scan_{time}_[zh|en]_{num}.xlsx。 |

扫描过程中支持“Ctrl+C”中止扫描,中止之后将输出当前已经扫描的数据。单个报告支持10000条数据。
使用示例
- 查看敏感词列表
1
devkit doctor sen-scan -S
返回信息如下:
1 2 3 4 5 6 7 8
id note ———————————————————————————————————————————————————————————— 1 Public IP address 2 Mobile number 3 ID number a Hard-coded key/Password (high false positive rate) b Common password text (high false positive rate) c Privacy sensitive words (high false positive rate)
- 生成敏感词模板
- 生成敏感词模板
以在“/home/temp”路径下生成模板为例,请根据实际情况进行替换。若不指定则默认在doctor目录下生成sen_word.json。
1
devkit doctor sen-scan -t /home/temp
显示信息如下,若该路径已存在同名文件,则文件名将会自动加1,如sen_word_1.json。
1
[INFO]Generating the template file in /home/temp/sen_word.json succeeded.
- 编辑模板文件。
1
vi /home/temp/sen_word.json
- 按“i”进入编辑模式,配置敏感词模板。
1 2 3 4 5 6 7 8 9 10 11 12
[ { "word": "", "word_type": "regex", "word_note": "" }, { "word": "", "word_type": "text", "word_note": "" } ]
- word:扫描的敏感词,与敏感词类型需要对应。
- word_type:敏感词类型。regex为正则表达式;text为文本样式。
- word_note:敏感词说明,可不填写。
- 生成敏感词模板
- 敏感信息扫描此处以扫描“/home/software/RuoYi-master/”并指定敏感词编码和模板为例,请根据实际情况替换成实际需要扫描的文件路径。
1
devkit doctor sen-scan -i /home/software/RuoYi-master/ -sn 1,2,3 -sf /home/temp/sen_word.json
返回信息如下,并输出报告。
1 2 3
[INFO]Start scan /home/software/RuoYi-master. [INFO]The scan is complete, starting to generate the report. Excel report is created successfully. Files are located in /usr/local/devkit/doctor/report/sen_scan/20240814101140
同时生成中英文扫描报告,报告包含总览、敏感词总览和详情三个页签,报告内容主要展示扫描路径、起止时间、是否中止、敏感词统计及详情等。
父主题: 等保密评