foundruu-plugin-security 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +25 -0
  2. package/index.js +45 -0
  3. package/package.json +18 -0
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # foundruu-plugin-security
2
+
3
+ [FoundRuu](https://github.com/Ruu5LP/foundruu) の公式プラグインサンプルです。
4
+ `foundruu doctor` にセキュリティ観点のチェックを追加します。
5
+
6
+ ## インストール
7
+
8
+ ```bash
9
+ npm install -D foundruu-plugin-security
10
+ ```
11
+
12
+ プロジェクトの `node_modules` に入っていれば自動で読み込まれます(設定不要)。
13
+
14
+ ## 追加されるチェック
15
+
16
+ | チェック | severity | 内容 |
17
+ |---|---|---|
18
+ | SECURITY.md | warn | 脆弱性報告窓口の明記 |
19
+ | .env が gitignore されている | error | 秘密情報のコミット防止 |
20
+ | 依存更新の自動化 | warn | Dependabot / Renovate の設定 |
21
+
22
+ ## プラグインを自作する
23
+
24
+ このパッケージの [index.js](index.js) が参考実装です。`foundruu-plugin-*` という名前で
25
+ `register({ program, addDoctorCheck, log })` をエクスポートするだけで動きます。
package/index.js ADDED
@@ -0,0 +1,45 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ /**
5
+ * FoundRuu 公式プラグインサンプル。
6
+ * doctor にセキュリティ観点のチェックを3つ追加する。
7
+ * プラグインの書き方の参考実装でもある(https://github.com/Ruu5LP/foundruu#プラグイン)。
8
+ */
9
+ module.exports = {
10
+ name: "security",
11
+ register({ addDoctorCheck }) {
12
+ addDoctorCheck({
13
+ id: "security-md",
14
+ label: "SECURITY.md",
15
+ category: "セキュリティ",
16
+ severity: "warn",
17
+ hint: "SECURITY.md で脆弱性の報告窓口を明記してください",
18
+ check: (ctx) => ctx.existsAny(["SECURITY.md", ".github/SECURITY.md"]),
19
+ });
20
+ addDoctorCheck({
21
+ id: "security-env-ignored",
22
+ label: ".env が gitignore されている",
23
+ category: "セキュリティ",
24
+ severity: "error",
25
+ hint: ".gitignore に .env を追加し、秘密情報のコミットを防いでください",
26
+ check: (ctx) => {
27
+ const gitignore = path.join(ctx.cwd, ".gitignore");
28
+ if (!fs.existsSync(gitignore)) return false;
29
+ return fs
30
+ .readFileSync(gitignore, "utf8")
31
+ .split(/\r?\n/)
32
+ .some((line) => /^\.env(\..*)?$|^\*\.env$/.test(line.trim()));
33
+ },
34
+ });
35
+ addDoctorCheck({
36
+ id: "security-deps-automation",
37
+ label: "依存更新の自動化 (Dependabot / Renovate)",
38
+ category: "セキュリティ",
39
+ severity: "warn",
40
+ hint: ".github/dependabot.yml または renovate.json を追加してください",
41
+ check: (ctx) =>
42
+ ctx.existsAny([".github/dependabot.yml", ".github/dependabot.yaml", "renovate.json", ".renovaterc.json"]),
43
+ });
44
+ },
45
+ };
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "foundruu-plugin-security",
3
+ "version": "0.1.0",
4
+ "description": "FoundRuu 公式プラグインサンプル - セキュリティ関連の doctor チェックを追加",
5
+ "license": "MIT",
6
+ "main": "index.js",
7
+ "files": ["index.js"],
8
+ "keywords": ["foundruu", "foundruu-plugin", "security"],
9
+ "author": "Ruu5LP",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/Ruu5LP/foundruu.git",
13
+ "directory": "plugins/foundruu-plugin-security"
14
+ },
15
+ "peerDependencies": {
16
+ "foundruu": ">=0.5.0"
17
+ }
18
+ }