d48cda4081
CI / Test (ubuntu-latest, Node 18.x, bun) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, npm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, pnpm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, yarn) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 20.x, bun) (push) Failing after 17m13s
CI / Test (ubuntu-latest, Node 20.x, npm) (push) Failing after 18m42s
CI / Test (ubuntu-latest, Node 20.x, pnpm) (push) Failing after 15m0s
CI / Test (ubuntu-latest, Node 20.x, yarn) (push) Failing after 49m44s
CI / Test (ubuntu-latest, Node 22.x, bun) (push) Failing after 51m55s
CI / Test (ubuntu-latest, Node 22.x, pnpm) (push) Failing after 21m57s
CI / Test (ubuntu-latest, Node 22.x, npm) (push) Failing after 37m39s
CI / Test (ubuntu-latest, Node 22.x, yarn) (push) Failing after 34m7s
CI / Validate Components (push) Failing after 37m15s
CI / Python Tests (push) Failing after 10m1s
CI / Security Scan (push) Failing after 10m1s
CI / Lint (push) Failing after 17m12s
CI / Coverage (push) Failing after 20m19s
CI / Test (macos-latest, Node 18.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, yarn) (push) Has been cancelled
70 lines
1.8 KiB
Markdown
70 lines
1.8 KiB
Markdown
---
|
||
paths:
|
||
- "**/*.pl"
|
||
- "**/*.pm"
|
||
- "**/*.t"
|
||
- "**/*.psgi"
|
||
- "**/*.cgi"
|
||
---
|
||
# Perl セキュリティ
|
||
|
||
> このファイルは [common/security.md](../common/security.md) を Perl 固有のコンテンツで拡張します。
|
||
|
||
## 汚染モード
|
||
|
||
- すべての CGI/Web 向けスクリプトで `-T` フラグを使用する
|
||
- 外部コマンド実行前に `%ENV`(`$ENV{PATH}`、`$ENV{CDPATH}` など)をサニタイズする
|
||
|
||
## 入力検証
|
||
|
||
- アンテイントには許可リスト正規表現を使用する — `/(.*)/s` は絶対に使用しない
|
||
- すべてのユーザー入力を明示的なパターンで検証する:
|
||
|
||
```perl
|
||
if ($input =~ /\A([a-zA-Z0-9_-]+)\z/) {
|
||
my $clean = $1;
|
||
}
|
||
```
|
||
|
||
## ファイル I/O
|
||
|
||
- **3引数 open のみ** — 2引数 open は使用しない
|
||
- `Cwd::realpath` でパストラバーサルを防止する:
|
||
|
||
```perl
|
||
use Cwd 'realpath';
|
||
my $safe_path = realpath($user_path);
|
||
die "Path traversal" unless $safe_path =~ m{\A/allowed/directory/};
|
||
```
|
||
|
||
## プロセス実行
|
||
|
||
- **リスト形式の `system()`** を使用する — 単一文字列形式は使用しない
|
||
- 出力キャプチャには **IPC::Run3** を使用する
|
||
- 変数補間付きのバッククォートは使用しない
|
||
|
||
```perl
|
||
system('grep', '-r', $pattern, $directory); # 安全
|
||
```
|
||
|
||
## SQL インジェクション防止
|
||
|
||
常に DBI プレースホルダを使用する — SQL に補間しない:
|
||
|
||
```perl
|
||
my $sth = $dbh->prepare('SELECT * FROM users WHERE email = ?');
|
||
$sth->execute($email);
|
||
```
|
||
|
||
## セキュリティスキャン
|
||
|
||
**perlcritic** をセキュリティテーマで重大度 4 以上で実行する:
|
||
|
||
```bash
|
||
perlcritic --severity 4 --theme security lib/
|
||
```
|
||
|
||
## リファレンス
|
||
|
||
スキル: `perl-security` で包括的な Perl セキュリティパターン、汚染モード、安全な I/O を参照してください。
|