Skip to content

Fix SRI calculation validation in calc_sri_fix.sh#268

Merged
myoshi2891 merged 2 commits into
mainfrom
dev-from-macmini
Feb 11, 2026
Merged

Fix SRI calculation validation in calc_sri_fix.sh#268
myoshi2891 merged 2 commits into
mainfrom
dev-from-macmini

Conversation

@myoshi2891

Copy link
Copy Markdown
Owner

No description provided.

@coderabbitai

coderabbitai Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

ウォークスルー

シェルスクリプト calc_sri_fix.shcalculate_sri 関数内で、ローカル変数の宣言、トラップコマンドのクォート改善、curl レスポンスの空文字列検証エラーハンドリングを追加しました。パブリック API に変更はありません。

変更内容

コホート / ファイル 概要
SRI 計算関数の改善
calc_sri_fix.sh
ローカル変数 (urltemp_filehash) の宣言を導入し、トラップコマンドで temp_file パスをクォート処理。curl 実行後の空レスポンス検証を追加してエラーを返すように改善。

推定コードレビュー労力

🎯 2 (Simple) | ⏱️ ~8 分

関連する可能性のあるプルリクエスト

ウサギの詩

🐰 ローカル変数で整理整頓、
トラップはしっかりクォートして防御。
空のレスポンス、もう逃さない、
SRI 計算がぐんと強くなった。
バグフィックスの魔法、✨ 完成!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning プルリクエストの説明が完全に欠落しており、変更内容についての情報がありません。 変更内容、目的、テスト方法などを説明するプルリクエストの説明を追加してください。
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The pull request title 'Fix SRI calculation validation in calc_sri_fix.sh' directly describes the main change: adding validation to detect empty responses and fixing SRI calculation issues in the calc_sri_fix.sh file.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev-from-macmini

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@calc_sri_fix.sh`:
- Line 27: 関数の一時ファイル削除が二重になっているため、rm -f "$temp_file" を削除してトラップ(trap ...
RETURN)に一任するか、逆にトラップを削除して手動管理に統一してください; 推奨は既に設定されている trap ... RETURN
に任せることで、該当箇所は temp_file 変数を参照している rm の行を削除し、trap が正しく一時ファイルを削除することを確認してください。
- Line 10: trap の定義でダブルクォートを使うと設定時に $temp_file が展開されてしまうので、trap "rm -f
\"$temp_file\"" RETURN を単一引用符を使って trap 'rm -f "$temp_file"' RETURN
のように修正し、トラップ実行時に変数が展開されるようにしてください(参照: 変数名 temp_file、コマンド mktemp、トラップ設定箇所の trap
... RETURN)。

Comment thread calc_sri_fix.sh
local temp_file
temp_file=$(mktemp)
trap 'rm -f "$temp_file"' RETURN
trap "rm -f \"$temp_file\"" RETURN

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

trap でダブルクォートを使用すると、$temp_file がトラップ定義時に展開されます。

ShellCheck SC2064 の指摘通り、ダブルクォートを使うと $temp_file はトラップ設定時に即座に展開されます。この場合、直前の mktemp の結果をキャプチャするため意図通りに動作しますが、シングルクォートを使用するのがより慣用的で安全です。

🔧 修正案
-    trap "rm -f \"$temp_file\"" RETURN
+    trap 'rm -f "$temp_file"' RETURN
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
trap "rm -f \"$temp_file\"" RETURN
trap 'rm -f "$temp_file"' RETURN
🧰 Tools
🪛 Shellcheck (0.11.0)

[warning] 10-10: Use single quotes, otherwise this expands now rather than when signalled.

(SC2064)

🤖 Prompt for AI Agents
In `@calc_sri_fix.sh` at line 10, trap の定義でダブルクォートを使うと設定時に $temp_file
が展開されてしまうので、trap "rm -f \"$temp_file\"" RETURN を単一引用符を使って trap 'rm -f
"$temp_file"' RETURN のように修正し、トラップ実行時に変数が展開されるようにしてください(参照: 変数名 temp_file、コマンド
mktemp、トラップ設定箇所の trap ... RETURN)。

Comment thread calc_sri_fix.sh
local hash
hash=$(openssl dgst -sha384 -binary < "$temp_file" | openssl base64 -A)
echo "$url sha384-$hash"
rm -f "$temp_file"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

rm -ftrap ... RETURN と重複しています。

Line 10 の trap ... RETURN がファンクション終了時に自動的にファイルを削除するため、この手動削除は不要です。削除するか、逆にトラップに依存せず手動管理に統一するか、どちらかに寄せてください。

♻️ トラップに任せる場合の修正案
     echo "$url sha384-$hash"
-    rm -f "$temp_file"
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
rm -f "$temp_file"
echo "$url sha384-$hash"
}
🤖 Prompt for AI Agents
In `@calc_sri_fix.sh` at line 27, 関数の一時ファイル削除が二重になっているため、rm -f "$temp_file"
を削除してトラップ(trap ... RETURN)に一任するか、逆にトラップを削除して手動管理に統一してください; 推奨は既に設定されている trap ...
RETURN に任せることで、該当箇所は temp_file 変数を参照している rm の行を削除し、trap
が正しく一時ファイルを削除することを確認してください。

@myoshi2891 myoshi2891 changed the title Dev from macmini Fix SRI calculation validation in calc_sri_fix.sh Feb 11, 2026
@myoshi2891 myoshi2891 merged commit 67ebd63 into main Feb 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant