-
Notifications
You must be signed in to change notification settings - Fork 12
penambahan kolom penggunaan tema di laporan desa #653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bb55d23
Merge remote-tracking branch 'origin/rilis-dev' into dev-535
pandigresik 5e12577
penambahan kolom penggunaan tema di laporan desa
pandigresik 1a3fdd1
Merge branch 'rilis-dev' into dev-646
vickyrolanda 8a56b4a
perbaikan test
pandigresik 6f04580
Merge branch 'rilis-dev' into dev-646
vickyrolanda 5eb8815
[ci skip] memutahirkan catatan rilis
vickyrolanda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <?php | ||
|
|
||
| namespace App\Services; | ||
|
|
||
| use App\Models\Desa; | ||
| use Illuminate\Support\Facades\Cache; | ||
|
|
||
| class TemaService | ||
| { | ||
| /** | ||
| * Cache key for sebutan desa list. | ||
| */ | ||
| private const CACHE_KEY = 'tema_list'; | ||
|
|
||
| /** | ||
| * Cache duration in hours. | ||
| */ | ||
| private const CACHE_DURATION_HOURS = 24; | ||
|
|
||
| /** | ||
| * Get all unique sebutan desa values from database. | ||
| * | ||
| * @return array<string> | ||
| */ | ||
| public function getList(): array | ||
| { | ||
| return Cache::remember(self::CACHE_KEY, now()->addDay(), function () { | ||
| $data = Desa::select('tema')->whereNotNull('tema') | ||
| ->distinct() | ||
| ->pluck('tema', 'tema') | ||
| ->toArray(); | ||
|
|
||
| // Sanitize setiap value untuk mencegah XSS | ||
| return array_map(function ($value) { | ||
| return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); | ||
| }, $data); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Clear the sebutan desa cache. | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function clearCache(): bool | ||
| { | ||
| return Cache::forget(self::CACHE_KEY); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[MEDIUM] 🔒 Security: Potensi Double Encoding pada Output Tema
Masalah:
Data tema dari database di-encode dengan
htmlspecialchars()di service layer, kemudian di-output lagi di Blade view dengan{{ }}yang juga melakukan HTML escaping. Ini menyebabkan double encoding yang bisa membuat karakter khusus ditampilkan sebagai entity HTML (contoh:&menjadi&amp;).Kode:
Risiko:
&,<,>,",'akan ditampilkan sebagai HTML entities (&,<, dll) di UIContoh Dampak:
Jika ada tema bernama
"Tema A & B"di database:"Tema A & B""Tema A &amp; B""Tema A & B"(salah tampilan)PoC (Chrome Console):
Fix:
Hapus
htmlspecialchars()dari service layer karena Blade sudah melakukan auto-escaping. Biarkan Blade yang handle output escaping:Penjelasan Fix:
{{ }}syntax sudah otomatis melakukanhtmlspecialchars()saat rendering{!! !!}(tapi tidak disarankan untuk user input)Catatan Tambahan:
getListForApi()yang melakukan encodingSebutanDesaService.phpyang juga melakukan hal serupaThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sudah mengikuti saran dari PR sebelumnya #649 (comment), jadi tetap gunakan htmlspecialchars