-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to scrub html from secret
This new option allows admins to enable or disable scrubbing html from secrets on view and store.
- Loading branch information
1 parent
e9dcf6e
commit 5c7b018
Showing
15 changed files
with
144 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[secret] | ||
age = 604800 | ||
scrub = 1 | ||
[passphrase] | ||
allow_blank = 0 | ||
[cookie] | ||
|
This file contains 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 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 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 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 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,39 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use FindBin (); | ||
use lib "$FindBin::RealBin/../../lib", "$FindBin::RealBin/../../../lib"; | ||
use Pasteburn::Test; | ||
use Pasteburn::Model::Secrets; | ||
|
||
SCRUB_SECRET_ENABLED: { | ||
note( 'scrub secret enabled' ); | ||
my $secret_non_html = 'blaine was here text'; | ||
my $secret = '</textarea><script>blaine was here script</script>' . $secret_non_html; | ||
my $passphrase = 'mypassphrase'; | ||
my $secret_obj = Pasteburn::Model::Secrets->new( secret => $secret, passphrase => $passphrase ); | ||
|
||
ok( $secret_obj->store( scrub => 1 ), 'store was successful' ); | ||
|
||
# here we're intentionally not scrubbing the outgoing secret because we need to ensure | ||
# scrubbing the secret inbound works correctly. | ||
my $decoded_secret = $secret_obj->decode_secret( passphrase => $passphrase ); | ||
is( $decoded_secret, $secret_non_html, 'returned secret only contains the non-html string' ) | ||
} | ||
|
||
SCRUB_SECRET_DISABLED: { | ||
note( 'scrub secret disabled' ); | ||
my $secret_non_html = 'blaine was here text'; | ||
my $secret = '</textarea><script>blaine was here script</script>' . $secret_non_html; | ||
my $passphrase = 'mypassphrase'; | ||
my $secret_obj = Pasteburn::Model::Secrets->new( secret => $secret, passphrase => $passphrase ); | ||
|
||
ok( $secret_obj->store( scrub => 0 ), 'store was successful' ); | ||
|
||
# here we're intentionally not scrubbing the outgoing secret because we need to ensure | ||
# scrubbing the secret inbound works correctly. | ||
my $decoded_secret = $secret_obj->decode_secret( passphrase => $passphrase ); | ||
is( $decoded_secret, $secret, 'returned secret contains the html and non-html string parts' ); | ||
} | ||
|
||
done_testing; |
This file contains 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,40 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use FindBin (); | ||
use lib "$FindBin::RealBin/../../lib", "$FindBin::RealBin/../../../lib"; | ||
use Pasteburn::Test; | ||
use Pasteburn::Model::Secrets; | ||
|
||
SCRUB_SECRET_ENABLED: { | ||
note( 'scrub secret enabled' ); | ||
my $secret_non_html = 'blaine was here text'; | ||
my $secret = '</textarea><script>blaine was here script</script>' . $secret_non_html; | ||
my $passphrase = 'mypassphrase'; | ||
my $secret_obj = Pasteburn::Model::Secrets->new( secret => $secret, passphrase => $passphrase ); | ||
|
||
# here we're intentionally not scrubbing the incoming secret because we need to ensure | ||
# decoding a secret with html works correctly. | ||
ok( $secret_obj->store, 'stored new secret' ); | ||
|
||
my $decoded_secret = $secret_obj->decode_secret( passphrase => $passphrase, scrub => 1 ); | ||
isnt( $decoded_secret, $secret, "returned secret doesn't match" ); | ||
is( $decoded_secret, $secret_non_html, 'returned secret only contains the non-html string' ); | ||
} | ||
|
||
SCRUB_SECRET_DISABLED: { | ||
note( 'scrub secret disabled' ); | ||
my $secret_non_html = 'blaine was here text'; | ||
my $secret = '</textarea><script>blaine was here script</script>' . $secret_non_html; | ||
my $passphrase = 'mypassphrase'; | ||
my $secret_obj = Pasteburn::Model::Secrets->new( secret => $secret, passphrase => $passphrase ); | ||
|
||
# here we're intentionally not scrubbing the incoming secret because we need to ensure | ||
# decoding a secret with html works correctly. | ||
ok( $secret_obj->store, 'stored new secret' ); | ||
|
||
my $decoded_secret = $secret_obj->decode_secret( passphrase => $passphrase, scrub => 0 ); | ||
is( $decoded_secret, $secret, 'returned secret contains the html and non-html string parts' ); | ||
} | ||
|
||
done_testing; |
This file contains 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 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 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 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 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