-
-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #1114 feat: Secret Scanning Alerts (haridarshan)
This PR was squashed before being merged into the 3.12-dev branch. Discussion ---------- Feature: - Secret Scanning Alerts Doc: - Secret Scanning doc Closes #1080 Commits ------- 98053b5 feat: Add Secret Scanning Alerts (Enterprise, Organization & Repository) 7b434a9 chore(styleci): apply styleci patch
- Loading branch information
1 parent
b0ce482
commit 113f6b3
Showing
13 changed files
with
405 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
## Enterprise / Secret Scanning API | ||
[Back to the "Enterprise API"](../../enterprise.md) | [Back to the navigation](../../README.md) | ||
|
||
# List secret-scanning alerts for an Enterprise | ||
|
||
https://docs.github.com/en/[email protected]/rest/secret-scanning#list-secret-scanning-alerts-for-an-enterprise | ||
|
||
```php | ||
$alerts = $client->api('enterprise')->secretScanning()->alerts('KnpLabs'); | ||
``` |
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,10 @@ | ||
## Organization / Secret Scanning API | ||
[Back to the "Organization API"](../../organization.md) | [Back to the navigation](../../README.md) | ||
|
||
# List secret-scanning alerts for an Organization | ||
|
||
https://docs.github.com/en/[email protected]/rest/secret-scanning#list-secret-scanning-alerts-for-an-organization | ||
|
||
```php | ||
$alerts = $client->api('organization')->secretScanning()->alerts('KnpLabs'); | ||
``` |
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,37 @@ | ||
## Repository / Secret Scanning API | ||
[Back to the "Repos API"](../../repos.md) | [Back to the navigation](../../README.md) | ||
|
||
# List secret-scanning alerts for a repository | ||
|
||
https://docs.github.com/en/[email protected]/rest/secret-scanning#list-secret-scanning-alerts-for-a-repository | ||
|
||
```php | ||
$alerts = $client->api('repos')->secretScanning()->alerts('KnpLabs', 'php-github-api'); | ||
``` | ||
|
||
# Get a secret-scanning alert | ||
|
||
https://docs.github.com/en/[email protected]/rest/secret-scanning#get-a-secret-scanning-alert | ||
|
||
```php | ||
$alert = $client->api('repos')->secretScanning()->getAlert('KnpLabs', 'php-github-api', $alertNumber); | ||
``` | ||
|
||
# Update a secret-scanning alert | ||
|
||
https://docs.github.com/en/[email protected]/rest/secret-scanning#update-a-secret-scanning-alert | ||
|
||
```php | ||
$client->api('repos')->secretScanning()->updateAlert('KnpLabs', 'php-github-api', $alertNumber, [ | ||
'state' => 'resolved', | ||
'resolution' => 'wont-fix' | ||
]); | ||
``` | ||
|
||
# List Locations for a secret-scanning alert | ||
|
||
https://docs.github.com/en/[email protected]/rest/secret-scanning#list-locations-for-a-secret-scanning-alert | ||
|
||
```php | ||
$locations = $client->api('repos')->secretScanning()->locations('KnpLabs', 'php-github-api', $alertNumber); | ||
``` |
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,21 @@ | ||
<?php | ||
|
||
namespace Github\Api\Enterprise; | ||
|
||
use Github\Api\AbstractApi; | ||
|
||
class SecretScanning extends AbstractApi | ||
{ | ||
/** | ||
* @link https://docs.github.com/en/[email protected]/rest/secret-scanning#list-secret-scanning-alerts-for-an-enterprise | ||
* | ||
* @param string $enterprise | ||
* @param array $params | ||
* | ||
* @return array|string | ||
*/ | ||
public function alerts(string $enterprise, array $params = []) | ||
{ | ||
return $this->get('/enterprises/'.rawurlencode($enterprise).'/secret-scanning/alerts', $params); | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace Github\Api\Organization; | ||
|
||
class SecretScanning extends \Github\Api\AbstractApi | ||
{ | ||
/** | ||
* @link https://docs.github.com/en/[email protected]/rest/secret-scanning#list-secret-scanning-alerts-for-an-organization | ||
* | ||
* @param string $organization | ||
* @param array $params | ||
* | ||
* @return array|string | ||
*/ | ||
public function alerts(string $organization, array $params = []) | ||
{ | ||
return $this->get('/orgs/'.rawurlencode($organization).'/secret-scanning/alerts', $params); | ||
} | ||
} |
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,64 @@ | ||
<?php | ||
|
||
namespace Github\Api\Repository; | ||
|
||
class SecretScanning extends \Github\Api\AbstractApi | ||
{ | ||
/** | ||
* @link https://docs.github.com/en/[email protected]/rest/secret-scanning#list-secret-scanning-alerts-for-a-repository | ||
* | ||
* @param string $username | ||
* @param string $repository | ||
* @param array $params | ||
* | ||
* @return array|string | ||
*/ | ||
public function alerts(string $username, string $repository, array $params = []) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/secret-scanning/alerts', $params); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/[email protected]/rest/secret-scanning#get-a-secret-scanning-alert | ||
* | ||
* @param string $username | ||
* @param string $repository | ||
* @param int $alertNumber | ||
* | ||
* @return array|string | ||
*/ | ||
public function getAlert(string $username, string $repository, int $alertNumber) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/secret-scanning/alerts/'.$alertNumber); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/[email protected]/rest/secret-scanning#update-a-secret-scanning-alert | ||
* | ||
* @param string $username | ||
* @param string $repository | ||
* @param int $alertNumber | ||
* @param array $params | ||
* | ||
* @return array|string | ||
*/ | ||
public function updateAlert(string $username, string $repository, int $alertNumber, array $params = []) | ||
{ | ||
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/secret-scanning/alerts/'.$alertNumber, $params); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/[email protected]/rest/secret-scanning#list-locations-for-a-secret-scanning-alert | ||
* | ||
* @param string $username | ||
* @param string $repository | ||
* @param int $alertNumber | ||
* @param array $params | ||
* | ||
* @return array|string | ||
*/ | ||
public function locations(string $username, string $repository, int $alertNumber, array $params = []) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/secret-scanning/alerts/'.$alertNumber.'/locations', $params); | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace Github\Tests\Api\Enterprise; | ||
|
||
use Github\Api\Enterprise\SecretScanning; | ||
use Github\Tests\Api\TestCase; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
|
||
class SecretScanningTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function shouldGetAlerts() | ||
{ | ||
$expectedArray = [ | ||
['number' => 1, 'state' => 'resolved', 'resolution' => 'false_positive'], | ||
['number' => 2, 'state' => 'open', 'resolution' => null], | ||
['number' => 3, 'state' => 'resolved', 'resolution' => 'wont_fix'], | ||
['number' => 4, 'state' => 'resolved', 'resolution' => 'revoked'], | ||
]; | ||
|
||
/** @var SecretScanning|MockObject $api */ | ||
$api = $this->getApiMock(); | ||
|
||
$api | ||
->expects($this->once()) | ||
->method('get') | ||
->with('/enterprises/KnpLabs/secret-scanning/alerts') | ||
->will($this->returnValue($expectedArray)); | ||
|
||
$this->assertEquals($expectedArray, $api->alerts('KnpLabs', [ | ||
'state' => 'all', | ||
])); | ||
} | ||
|
||
protected function getApiClass() | ||
{ | ||
return \Github\Api\Enterprise\SecretScanning::class; | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace Github\Tests\Api\Organization; | ||
|
||
use Github\Api\Organization\SecretScanning; | ||
use Github\Tests\Api\TestCase; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
|
||
class SecretScanningTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function shouldGetAlerts() | ||
{ | ||
$expectedArray = [ | ||
['number' => 1, 'state' => 'resolved', 'resolution' => 'false_positive'], | ||
['number' => 2, 'state' => 'open', 'resolution' => null], | ||
['number' => 3, 'state' => 'resolved', 'resolution' => 'wont_fix'], | ||
['number' => 4, 'state' => 'resolved', 'resolution' => 'revoked'], | ||
]; | ||
|
||
/** @var SecretScanning|MockObject $api */ | ||
$api = $this->getApiMock(); | ||
|
||
$api | ||
->expects($this->once()) | ||
->method('get') | ||
->with('/orgs/KnpLabs/secret-scanning/alerts') | ||
->will($this->returnValue($expectedArray)); | ||
|
||
$this->assertEquals($expectedArray, $api->alerts('KnpLabs', [ | ||
'state' => 'all', | ||
])); | ||
} | ||
|
||
protected function getApiClass() | ||
{ | ||
return \Github\Api\Organization\SecretScanning::class; | ||
} | ||
} |
Oops, something went wrong.