我可以使用以下命令通过snyk运行iac扫描仪:
$ npm install -g snyk
$ snyk auth my-hash-api-token-key
$ snyk iac test /path/to/my/terraform.tf
我尝试使用以下格式将这些命令打包到一个bash脚本中
#!/bin/bash
token=$1
directory=$2
echo "PERFORMING SNYK SCAN"
echo "INSTALL SNYK"
npm install -g snyk
echo "AUTHENTICATE TO SNYK PORTAL"
snyk auth ${token}
echo "PERFORM SNYK TEST"
snyk iac test ${directory}
然而,我总是从terminal =/usr/bin/env得到这个结果:node:No such file or directoryand looking to apackage.json在执行下面的wrapper脚本时的示例输出:
$ pwd
/home/user
$ ls -ltrh
total 0
drwxrwxr-x 3 user user 59 Feb 22 08:55 terraform-files
$ my-wrapper-script.sh my-hash-api-token-key /home/user/terraform-files
PERFORMING SNYK SCAN
INSTALL SNYK
/usr/bin/snyk -> /usr/lib/node_modules/snyk/dist/cli/index.js
+ snyk@1.458.0
updated 1 package in 11.49s
AUTHENTICATE TO SNYK PORTAL
Authenticating
PERFORM SNYK TEST
npm WARN saveError ENOENT: no such file or directory, open '/home/user/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/user/package.json'
npm WARN SOURCE_REPO_FOLDER No description
npm WARN SOURCE_REPO_FOLDER No repository field.
npm WARN SOURCE_REPO_FOLDER No README data
npm WARN SOURCE_REPO_FOLDER No license field.
/usr/bin/env: node: No such file or directory
/usr/bin/env: node: No such file or directory
PS:我也尝试了我在其他文章中找到的建议解决方案,比如在nodejs和node上创建sym链接,但这不适用,因为我已经在我的盒子上有了node。我对npm/node的了解仍然有限。我的目标是使扫描工作
1条答案
按热度按时间8hhllhi21#
对不起,我失去了联系,这个问题已经解决了。我们已经从 Package 器脚本中删除了snyk,并使用不同的方法来运行它。我们可以结案的