Open ghost opened 3 years ago
@pr-ema コメントして頂きありがとうございました。 問題があるところを修正しました。コードレビューお願いします。https://github.com/prNguyenVietThai/backend-kenshyu/commit/bd924f80253558edd61bd736c6afbfce13e1e8a2
@prNguyenVietThai ご対応ありがとうございます!ほとんど問題なく、Webアプリケーションとして完成しています! 2点ほど、細かいですが改善できる点がありました。
[GOOD]
URL設計・ルーティングの実装がきれいに出いていて、素晴らしいです👍
[NITS]
https://github.com/prNguyenVietThai/backend-kenshyu/blob/941858c7433a0bf5f4c1b4e401ebe3614a7d8518/src/core/Database.php#L3-L6 パスワード等の情報は基本的にハードコーディングせずに環境変数で設定します。 今回Dockerを使って環境構築しているので、Dockerで環境変数を設定するやり方など学べると良いでしょう
[MUST]
記事の投稿・編集画面でCSRF対策をするようにしてください。 参考書:体系的に学ぶ安全なWebアプリケーションの作り方:p141
[MUST]
https://github.com/prNguyenVietThai/backend-kenshyu/blob/c28198447c0540afd2e196417838db4877e28f6f/src/controllers/PostController.php#L37-L81 (ここだけではないですが、)複数の処理を同時に行う場合はトランザクションをしましょう。
[GOOD]
や
は、MVCの設計が良く出来ていると見受けられます👍
[MUST]
https://github.com/prNguyenVietThai/backend-kenshyu/blob/673e2c6af6864ce4eb02b3a7f73cffabd69c7210/src/services/TagServices.php#L37-L53 (ここだけではないですが、)SQLインジェクション対策はSQLを発行する場所全てで行うようにしましょう
getByPostId(int $postId)
は実装上$postId
に整数しか入らないようになっていますが、今後このプログラムを書き換える時に意図せず文字列が入っていしまう事もあるかもしれません。 そのため、変数の型などの実装に依存せずに、必ずSQLインジェクション対策は行う心構えでいる事が望ましいです[MUST]
XSSが出来てしまうので、最低限のエスケープ処理などのXSS対策をお願いします 参考書:体系的に学ぶ安全なWebアプリケーションの作り方:p88
[IMO]
(修正する必要は無いです) PR TIMESではコードのクオリティを担保するためにcodeclimateを導入しています。実装やフレームワーク的に全て直す事は困難だと思いますので、参考程度に結果を載せておきます。
[NITS]
DDLを
/src/database
以下に入れていますが、例えば localhost:8080/database/db_v2.sql などにアクセスすると外部の人にバレてしまうので、backend-kenshyu/src/database/
ではなくbackend-kenshyu/database/
にしたほうが良いかと思います