Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/research/ export-ignore
/tests/ export-ignore
/.gitattributes export-ignore
/.gitleaks.toml export-ignore
/.gitignore export-ignore
/.editorconfig export-ignore
/BUILD-LOG.md export-ignore
Expand Down
2 changes: 2 additions & 0 deletions .gitguardian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
version: 2

secret:
ignored_paths:
- "tests/Fixtures/**/*"
ignored-matches:
# --- Still on `KEY=value` lines in the current tree, so these are the
# --- entries actually doing work.
Expand Down
12 changes: 12 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# gitleaks policy. Written by agent-kit's secret_scan.py; extend it by hand, narrowly.
# Only named fixture and example-env paths are allowlisted; secret_scan.py still
# searches them for live-format keys. A realistic fake elsewhere carries an inline
# `gitleaks:allow` comment instead.
[extend]
useDefault = true

[[allowlists]]
description = "Named fixture and example-env paths (agent-kit secret_scan.py)"
paths = [
'''^tests/Fixtures/(?:.*/)?[^/]*$''',
]
12 changes: 6 additions & 6 deletions tests/Feature/EncryptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@
});

it('encrypts a value at rest and decrypts it back', function () {
$path = $this->bindEnv("API_TOKEN=plaintext-secret\n", ['laranail.env-kit.auto_backup' => false]);
$path = $this->bindEnv("API_TOKEN=test-secret-not-real\n", ['laranail.env-kit.auto_backup' => false]);

EnvKit::encrypt('API_TOKEN');

// at rest the file holds ciphertext, not the plaintext
$raw = (string) file_get_contents($path);
expect($raw)->not->toContain('plaintext-secret')
expect($raw)->not->toContain('test-secret-not-real')
->and($raw)->toContain('envkit:');

// get() returns the at-rest ciphertext; getDecrypted() returns the plaintext
expect(EnvKit::get('API_TOKEN'))->not->toBe('plaintext-secret')
->and(EnvKit::getDecrypted('API_TOKEN'))->toBe('plaintext-secret');
expect(EnvKit::get('API_TOKEN'))->not->toBe('test-secret-not-real')
->and(EnvKit::getDecrypted('API_TOKEN'))->toBe('test-secret-not-real');

// decrypt() restores plaintext at rest
EnvKit::decrypt('API_TOKEN');
expect((string) file_get_contents($path))->toContain('API_TOKEN=plaintext-secret')
->and(EnvKit::get('API_TOKEN'))->toBe('plaintext-secret');
expect((string) file_get_contents($path))->toContain('API_TOKEN=test-secret-not-real')
->and(EnvKit::get('API_TOKEN'))->toBe('test-secret-not-real');
});

it('setEncrypted stores ciphertext that getDecrypted reads back', function () {
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/SecretLeakTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
});

it('scrubs a secret out of any message via the redactor', function () {
$secret = 'super-secret-token-ABC123';
$secret = 'test-secret-not-real';

$scrubbed = (new SecretRedactor)->scrub("dsn=postgres://u:{$secret}@h/db", [$secret]);
$scrubbed = (new SecretRedactor)->scrub('dsn=postgres://u:' . $secret . '@h/db', [$secret]);

expect($scrubbed)->not->toContain($secret);
});
Loading