Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Aug 2, 2023
1 parent 61450fa commit 7bb79ee
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
72 changes: 72 additions & 0 deletions ghsa/ghsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,78 @@ func TestConfig_Update(t *testing.T) {
},
expectedErrorMsg: "",
},
{
name: "happy path with correct swift dir name",
appFs: afero.NewMemMapFs(),
inputEcosystem: Swift,
goldenFiles: map[string]string{
"/tmp/ghsa/swift/github.com/grpc/grpc-swift/GHSA-r6ww-5963-7r95.json": "testdata/swift/github.com/grpc/grpc-swift/GHSA-r6ww-5963-7r95.json",
},
inputResponse: map[githubql.String]GetVulnerabilitiesQuery{
githubql.String(""): {
SecurityVulnerabilities: SecurityVulnerabilities{
Nodes: []GithubSecurityAdvisory{
{
Severity: "HIGH",
UpdatedAt: "2023-06-09T19:33:17Z",
Package: Package{
Ecosystem: "SWIFT",
Name: "https://github.com/grpc/grpc-swift.git",
},
Advisory: Advisory{
DatabaseId: 212034,
Id: "GSA_kwCzR0hTQS1yNnd3LTU5NjMtN3I5Nc4AAzxC",
GhsaId: "GHSA-r6ww-5963-7r95",
References: []Reference{
{
Url: "https://github.com/grpc/grpc-swift/security/advisories/GHSA-r6ww-5963-7r95",
},
{
Url: "https://nvd.nist.gov/vuln/detail/CVE-2022-24777",
},
{
Url: "https://github.com/grpc/grpc-swift/commit/858f977f2a51fca2292f384cf7a108dc2e73a3bd",
},
{
Url: "https://github.com/advisories/GHSA-r6ww-5963-7r95",
},
},
Identifiers: []Identifier{
{
Type: "GHSA",
Value: "GHSA-r6ww-5963-7r95",
},
{
Type: "CVE",
Value: "CVE-2022-24777",
},
},
Description: "A grpc-swift server is vulnerable to a denial of service attack via a reachable assertion. This was due to incorrect logic when handling `GOAWAY` frames.\n\nThe attack is low-effort: it takes very little resources to construct and send the required sequence of frames. The impact on availability is high as the server will crash, dropping all in flight connections and requests.\n\nThe issue was discovered by automated fuzz testing and is resolved by fixing the relevant state handling code.",
Origin: "UNSPECIFIED",
PublishedAt: "2023-06-09T19:33:16Z",
Severity: "HIGH",
Summary: "Denial of Service via reachable assertion",
UpdatedAt: "2023-06-19T16:45:07Z",
WithdrawnAt: "",
CVSS: GithubCVSS{
Score: 7.5,
VectorString: "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
},
},
FirstPatchedVersion: FirstPatchedVersion{
Identifier: "1.7.2",
},
VulnerableVersionRange: "\u003c 1.7.2",
},
},
PageInfo: PageInfo{
EndCursor: githubql.String(""),
HasNextPage: false,
},
},
},
},
},
{
name: "read only filesystem test",
appFs: afero.NewReadOnlyFs(afero.NewOsFs()),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"Severity": "HIGH",
"UpdatedAt": "2023-06-09T19:33:17Z",
"Package": {
"Ecosystem": "SWIFT",
"Name": "https://github.com/grpc/grpc-swift.git"
},
"Advisory": {
"DatabaseId": 212034,
"Id": "GSA_kwCzR0hTQS1yNnd3LTU5NjMtN3I5Nc4AAzxC",
"GhsaId": "GHSA-r6ww-5963-7r95",
"References": [
{
"Url": "https://github.com/grpc/grpc-swift/security/advisories/GHSA-r6ww-5963-7r95"
},
{
"Url": "https://nvd.nist.gov/vuln/detail/CVE-2022-24777"
},
{
"Url": "https://github.com/grpc/grpc-swift/commit/858f977f2a51fca2292f384cf7a108dc2e73a3bd"
},
{
"Url": "https://github.com/advisories/GHSA-r6ww-5963-7r95"
}
],
"Identifiers": [
{
"Type": "GHSA",
"Value": "GHSA-r6ww-5963-7r95"
},
{
"Type": "CVE",
"Value": "CVE-2022-24777"
}
],
"Description": "A grpc-swift server is vulnerable to a denial of service attack via a reachable assertion. This was due to incorrect logic when handling `GOAWAY` frames.\n\nThe attack is low-effort: it takes very little resources to construct and send the required sequence of frames. The impact on availability is high as the server will crash, dropping all in flight connections and requests.\n\nThe issue was discovered by automated fuzz testing and is resolved by fixing the relevant state handling code.",
"Origin": "UNSPECIFIED",
"PublishedAt": "2023-06-09T19:33:16Z",
"Severity": "HIGH",
"Summary": "Denial of Service via reachable assertion",
"UpdatedAt": "2023-06-19T16:45:07Z",
"WithdrawnAt": "",
"CVSS": {
"Score": 7.5,
"VectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
}
},
"Versions": [
{
"FirstPatchedVersion": {
"Identifier": "1.7.2"
},
"VulnerableVersionRange": "\u003c 1.7.2"
}
]
}

0 comments on commit 7bb79ee

Please sign in to comment.