Skip to content

Commit

Permalink
Create exposed-backup-file.bcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
pselliotc authored Oct 16, 2023
1 parent 08b2196 commit 642fce2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/exposed-backup-file.bcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
metadata:
language: v2-beta
name: "Path-level"
description: "Tests for exposed backup files"
author: "Carlos Montoya"

run for each:
# you could add more values to this list to make the check repeat
extension =
".bak",
".back",
".backup",
".old"

given path then
if not ({base.response.status_code} is "404") then
send request called check:
replacing path: {regex_replace ({base.response.url.path}, "(.)/?$", `$1{extension}`)}

if {check.response.status_code} is {base.response.status_code} then
send request called garbage:
replacing path: {regex_replace ({base.response.url.path}, "(.)/?$", `$1.{random_str(10)}`)}
if {garbage} differs from {check} then
report issue and continue:
severity: info
confidence: firm
detail: `Backup file found at {check.request.url}`
remediation: "Ensure your backup files are not exposed."
end if
end if
end if

0 comments on commit 642fce2

Please sign in to comment.