Skip to content

Commit f656e2b

Browse files
authored
Support decoding security_advisory events + dependency update (#369)
1 parent 88babfb commit f656e2b

File tree

7 files changed

+103
-34
lines changed

7 files changed

+103
-34
lines changed

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
"workbench.editor.enablePreview": false,
8686
"yaml.format.enable": true,
8787
"yaml.maxItemsComputed": 1000000,
88-
"swift.debugger.debugAdapter": "CodeLLDB"
8988
"swift.debugger.debugAdapter": "CodeLLDB",
9089
"swift.buildArguments": ["--enable-experimental-prebuilts"]
9190
}

Lambdas/GHHooks/EventHandler/EventHandler.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ struct EventHandler: Sendable {
2121
try await onPing()
2222
case .sponsorship:
2323
try await onSponsorship()
24-
case .pull_request_review, .projects_v2_item, .project_card, .label, .installation_repositories:
24+
case .pull_request_review,
25+
.projects_v2_item,
26+
.project_card,
27+
.label,
28+
.installation_repositories,
29+
.security_advisory:
2530
break
2631
default:
2732
try await onDefault()

Lambdas/GHHooks/EventHandler/Handlers/IssueHandler.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ struct IssueHandler: Sendable {
179179
if issue.closedAt == nil {
180180
return nil
181181
}
182+
let sender = try event.sender.requireValue()
182183
if action == .closed {
183-
return (event.sender.id, event.sender.uiName)
184+
return (sender.id, sender.uiName)
184185
} else {
185186
return try await context.githubClient.issuesGet(
186187
path: .init(

Lambdas/GitHubAPI/GHEvent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Foundation
77
/// https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads
88
package struct GHEvent: Sendable, Codable {
99
package let action: String?
10-
package let sender: User
10+
package let sender: User?
1111
package let repository: Repository?
1212

1313
package let issue: Issue?

Package.resolved

Lines changed: 30 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/PennyTests/Tests/GHHooksTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,15 @@ actor GHHooksTests {
10801080
)
10811081
}
10821082

1083+
@Test
1084+
func handleSecurityAdvisory1() async throws {
1085+
try await handleEvent(
1086+
key: "security_advisory1",
1087+
eventName: .security_advisory,
1088+
expect: .noResponse
1089+
)
1090+
}
1091+
10831092
@Test
10841093
func handleOtherEvent1() async throws {
10851094
try await handleEvent(

Tests/Resources/ghHooksEvents.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12156,5 +12156,60 @@
1215612156
"type": "User",
1215712157
"site_admin": false
1215812158
}
12159+
},
12160+
"security_advisory1": {
12161+
"action": "published",
12162+
"security_advisory": {
12163+
"ghsa_id": "GHSA-qq7f-c3gc-q93g",
12164+
"cve_id": null,
12165+
"summary": "Malware in verror-extra",
12166+
"description": "Any computer that has this package installed or running should be considered fully compromised. All secrets and keys stored on that computer should be rotated immediately from a different computer. The package should be removed, but as full control of the computer may have been given to an outside entity, there is no guarantee that removing the package will remove all malicious software resulting from installing it.",
12167+
"severity": "critical",
12168+
"identifiers": [
12169+
{
12170+
"value": "GHSA-qq7f-c3gc-q93g",
12171+
"type": "GHSA"
12172+
}
12173+
],
12174+
"references": [
12175+
{
12176+
"url": "https://github.com/advisories/GHSA-qq7f-c3gc-q93g"
12177+
}
12178+
],
12179+
"published_at": "2025-09-16T07:57:02Z",
12180+
"updated_at": "2025-09-16T07:57:02Z",
12181+
"withdrawn_at": null,
12182+
"vulnerabilities": [
12183+
{
12184+
"package": {
12185+
"ecosystem": "npm",
12186+
"name": "verror-extra"
12187+
},
12188+
"severity": "critical",
12189+
"vulnerable_version_range": ">= 0",
12190+
"first_patched_version": null
12191+
}
12192+
],
12193+
"cvss_severities": {
12194+
"cvss_v3": {
12195+
"vector_string": null,
12196+
"score": 0
12197+
},
12198+
"cvss_v4": {
12199+
"vector_string": null,
12200+
"score": 0
12201+
}
12202+
},
12203+
"cvss": {
12204+
"vector_string": null,
12205+
"score": 0
12206+
},
12207+
"cwes": [
12208+
{
12209+
"cwe_id": "CWE-506",
12210+
"name": "Embedded Malicious Code"
12211+
}
12212+
]
12213+
}
1215912214
}
1216012215
}

0 commit comments

Comments
 (0)