Skip to content

Commit 0232c67

Browse files
Fix style issues
1 parent 0095032 commit 0232c67

2 files changed

Lines changed: 45 additions & 42 deletions

File tree

src/Regex/Supplier/Gitlab.php

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,31 @@
2323
* @package CaptainHook-Secrets
2424
* @since Class available since Release 0.9.6
2525
*/
26-
final class Gitlab implements Supplier {
27-
28-
/**
29-
* Sourced from https://github.com/gitlabhq/gitlabhq/blob/master/gems/gitlab-secret_detection/lib/gitleaks.toml#L4-L51
30-
* @return string[]
31-
*/
32-
public function patterns(): array {
33-
return [
34-
// GitLab Personal Access Token
35-
'#' . Util::OPTIONAL_QUOTE . '(glpat-[0-9a-zA-Z_\\-]{20})' . Util::OPTIONAL_QUOTE . '#',
36-
// GitLab Pipeline Trigger Token
37-
'#' . Util::OPTIONAL_QUOTE . '(glptt-[0-9a-zA-Z_\\-]{40})' . Util::OPTIONAL_QUOTE . '#',
38-
// GitLab Runner Registration Token
39-
'#' . Util::OPTIONAL_QUOTE . '(GR1348941[0-9a-zA-Z_\\-]{20})' . Util::OPTIONAL_QUOTE . '#',
40-
// GitLab OAuth Application Secrets
41-
'#' . Util::OPTIONAL_QUOTE . '(gloas-[0-9a-zA-Z_\\-]{64})' . Util::OPTIONAL_QUOTE . '#',
42-
// GitLab Feed token
43-
'#' . Util::OPTIONAL_QUOTE . '(glft-[0-9a-zA-Z_\\-]{20})' . Util::OPTIONAL_QUOTE . '#',
44-
// GitLab Agent for Kubernetes token
45-
'#' . Util::OPTIONAL_QUOTE . '(glagent-[0-9a-zA-Z_\\-]{50})' . Util::OPTIONAL_QUOTE . '#',
46-
// GitLab Incoming email token
47-
'#' . Util::OPTIONAL_QUOTE . '(glimt-[0-9a-zA-Z_\\-]{25})' . Util::OPTIONAL_QUOTE . '#',
48-
];
49-
}
50-
}
26+
final class Gitlab implements Supplier
27+
{
28+
/**
29+
* Sourced from the gitlab secret detection
30+
* https://github.com/gitlabhq/gitlabhq/blob/master/gems/gitlab-secret_detection/lib/gitleaks.toml#L4-L51
31+
*
32+
* @return string[]
33+
*/
34+
public function patterns(): array
35+
{
36+
return [
37+
// GitLab Personal Access Token
38+
'#' . Util::OPTIONAL_QUOTE . '(glpat-[0-9a-zA-Z_\\-]{20})' . Util::OPTIONAL_QUOTE . '#',
39+
// GitLab Pipeline Trigger Token
40+
'#' . Util::OPTIONAL_QUOTE . '(glptt-[0-9a-zA-Z_\\-]{40})' . Util::OPTIONAL_QUOTE . '#',
41+
// GitLab Runner Registration Token
42+
'#' . Util::OPTIONAL_QUOTE . '(GR1348941[0-9a-zA-Z_\\-]{20})' . Util::OPTIONAL_QUOTE . '#',
43+
// GitLab OAuth Application Secrets
44+
'#' . Util::OPTIONAL_QUOTE . '(gloas-[0-9a-zA-Z_\\-]{64})' . Util::OPTIONAL_QUOTE . '#',
45+
// GitLab Feed token
46+
'#' . Util::OPTIONAL_QUOTE . '(glft-[0-9a-zA-Z_\\-]{20})' . Util::OPTIONAL_QUOTE . '#',
47+
// GitLab Agent for Kubernetes token
48+
'#' . Util::OPTIONAL_QUOTE . '(glagent-[0-9a-zA-Z_\\-]{50})' . Util::OPTIONAL_QUOTE . '#',
49+
// GitLab Incoming email token
50+
'#' . Util::OPTIONAL_QUOTE . '(glimt-[0-9a-zA-Z_\\-]{25})' . Util::OPTIONAL_QUOTE . '#',
51+
];
52+
}
53+
}

tests/Regex/Supplier/GitlabTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77

88
final class GitlabTest extends TestCase
99
{
10-
public function testDetectSecret(): void
11-
{
12-
$haystack = 'bar glpat-mBvGsDcJUvxvFZktWpzz baz';
13-
$detector = Detector::create()->useSuppliers(new Gitlab());
14-
$result = $detector->detectIn($haystack);
10+
public function testDetectSecret(): void
11+
{
12+
$haystack = 'bar glpat-mBvGsDcJUvxvFZktWpzz baz';
13+
$detector = Detector::create()->useSuppliers(new Gitlab());
14+
$result = $detector->detectIn($haystack);
1515

16-
$this->assertTrue($result->wasSecretDetected());
17-
$this->assertCount(1, $result->matches());
18-
}
16+
$this->assertTrue($result->wasSecretDetected());
17+
$this->assertCount(1, $result->matches());
18+
}
1919

20-
public function testDontDetectSecret(): void
21-
{
22-
$haystack = 'bar glpat-mBvGsDcJUvx... gitlab glpat-15487234 glpat-mBvG{}_JUvxvFZktWpzz';
23-
$detector = Detector::create()->useSuppliers(new Gitlab());
24-
$result = $detector->detectIn($haystack);
20+
public function testDontDetectSecret(): void
21+
{
22+
$haystack = 'bar glpat-mBvGsDcJUvx... gitlab glpat-15487234 glpat-mBvG{}_JUvxvFZktWpzz';
23+
$detector = Detector::create()->useSuppliers(new Gitlab());
24+
$result = $detector->detectIn($haystack);
2525

26-
$this->assertFalse($result->wasSecretDetected());
27-
$this->assertCount(0, $result->matches());
28-
}
29-
}
26+
$this->assertFalse($result->wasSecretDetected());
27+
$this->assertCount(0, $result->matches());
28+
}
29+
}

0 commit comments

Comments
 (0)