LoginSignup
4
2

More than 1 year has passed since last update.

この記事は アドベントカレンダー Snyk を使ってセキュリティにまつわる記事を投稿しよう!【PR】Snyk の 23 日目の記事です。

snyk と Windows

snyk( https://snyk.io/ ) は、脆弱性を診断するためのアプリケーションです。
CI に組み込んだりできるので、どちらかというと開発者向けのアプリという感じですね。

今回は、何を考えたのか、Windowsで使ってみようということで、インストールしてみました。
ちょっと、ひっかかるとことかあったので、そのあたりを中心に書いていきます。

実行環境:Windows10

なんか、PowerShell を使うらしい

Windows で snyk を実行するには、PowerShell を使うらしいっす。
普段 Linux ばかり使ってるので、PowerShell なんてほとんど使ったことないんですが・・・
(なら、なんで Linux でやらんのや?って声が聞こえてくる気がする・・・)

とりあえず PowerShell 起動してみるってよ

まぁ、普通に起動しますよね。

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
新しいクロスプラットフォームの PowerShell をお試しください https://aka.ms/pscore6                              
PS C:\WINDOWS\system32>

なんか、scoop っちゅうのがいるらしいので・・・

インストール手順見ると・・・・
https://docs.snyk.io/features/snyk-cli/install-the-snyk-cli#scoop-windows

scoop 使う前提で書いてあるけど、scoop って何だよって話で・・・
とりあえず、これっぽいのはわかったので、入れてみます。

PS C:\WINDOWS\system32> iwr -useb get.scoop.sh | iex
PowerShell requires an execution policy in [Unrestricted, RemoteSigned, ByPass] to run Scoop.
For example, to set the execution policy to 'RemoteSigned' please run :
'Set-ExecutionPolicy RemoteSigned -scope CurrentUser'

権限足りない?

権限必要って言われたので、とりあえず書いてある通りやってみます。

PS C:\WINDOWS\system32> Set-ExecutionPolicy RemoteSigned -scope CurrentUser
実行ポリシーの変更
実行ポリシーは、信頼されていないスクリプトからの保護に役立ちます。実行ポリシーを変更すると、about_Execution_Policies
のヘルプ トピック (https://go.microsoft.com/fwlink/?LinkID=135170)
で説明されているセキュリティ上の危険にさらされる可能性があります。実行ポリシーを変更しますか?
[Y] はい(Y)  [A] すべて続行(A)  [N] いいえ(N)  [L] すべて無視(L)  [S] 中断(S)  [?] ヘルプ (既定値は "N"): y

再チャレンジ

では、もう一回いってみましょう。

PS C:\WINDOWS\system32> iwr -useb get.scoop.sh | iex
Initializing...
Downloading scoop...
Extracting...
Creating shim...
Downloading main bucket...
Extracting...
Adding ~\scoop\shims to your path.
'lastupdate' has been set to '2021-12-17T11:19:49.9683903+09:00'
Scoop was installed successfully!
Type 'scoop help' for instructions.

お、なんか入ったっぽいですね。

では、snyk 入れていきます

PS C:\WINDOWS\system32> scoop bucket add snyk https://github.com/snyk/scoop-snyk
Git is required for buckets. Run 'scoop install git' and try again.

git がないって言われたあるよ・・・

git を突っ込む

PS C:\WINDOWS\system32> scoop install git
Installing '7zip' (21.06) [64bit]
7z2106-x64.msi (1.8 MB) [=====================================================================================] 100%
Checking hash of 7z2106-x64.msi ... ok.
install-context.reg (764 B) [=================================================================================] 100%
Checking hash of install-context.reg ... ok.
uninstall-context.reg (498 B) [===============================================================================] 100%
Checking hash of uninstall-context.reg ... ok.
Extracting 7z2106-x64.msi ... done.
Running pre-install script...
Linking ~\scoop\apps\7zip\current => ~\scoop\apps\7zip\21.06
Creating shim for '7z'.
Creating shortcut for 7-Zip (7zFM.exe)
Persisting Codecs
Persisting Formats
'7zip' (21.06) was installed successfully!
Notes
-----
Add 7-Zip as a context menu option by running: "C:\Users\Kaoru\scoop\apps\7zip\current\install-context.reg"
Installing 'git' (2.34.1.windows.1) [64bit]
PortableGit-2.34.1-64-bit.7z.exe (44.0 MB) [==================================================================] 100%
Checking hash of PortableGit-2.34.1-64-bit.7z.exe ... ok.
Extracting dl.7z ... done.
Linking ~\scoop\apps\git\current => ~\scoop\apps\git\2.34.1.windows.1
Creating shim for 'git'.
Creating shim for 'gitk'.
Creating shim for 'git-gui'.
Creating shim for 'tig'.
Creating shim for 'git-bash'.
Creating shortcut for Git Bash (git-bash.exe)
Creating shortcut for Git GUI (git-gui.exe)
'git' (2.34.1.windows.1) was installed successfully!
Notes
-----
Set Git Credential Manager Core by running: "git config --global credential.helper manager-core"

では気を取り直して・・・

PS C:\WINDOWS\system32> scoop bucket add snyk https://github.com/snyk/scoop-snyk
Checking repo... ok
The snyk bucket was added successfully.
PS C:\WINDOWS\system32> scoop install snyk
Installing 'snyk' (v1.794.0) [64bit]
snyk-win.exe (40.8 MB) [======================================================================================] 100%
Checking hash of snyk-win.exe ... ok.
Linking ~\scoop\apps\snyk\current => ~\scoop\apps\snyk\v1.794.0
Creating shim for 'snyk'.
'snyk' (v1.794.0) was installed successfully!

おー入った!!パチパチパチ

まとめ

実際に動かした記事は他のアドベントカレンダーでいっぱいあがっているので、たまにはこういう記事もいいんじゃないかと書いてみました。PowerShellなんて使う頻度少ないので、少してこずりましたが、入れてしまえばちゃんと動くので、そのあたりは良かったです。Log4jの脆弱性が世の中を騒がせている中で、こういう脆弱性診断してくれるソフトは今後ますます必要になってくると思うので、ちゃんと使えるようになっていきたいですね。

参照リンク

おまけ

今日は、自分の誕生日・・・祝日じゃなくなったけどw

4
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2