Skip to content

Commit 8bf7faa

Browse files
committed
fix: correctly parse revocation reason from issue
1 parent 19d295a commit 8bf7faa

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

generate-crl.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,33 @@ function extractSerialNumberFromBody (body) {
7474
function extractRevocationReason (body) {
7575
if (!body) return 'unspecified'
7676

77-
const reasonMatch = body.match(/reason[:]\s*(\w+)/i)
78-
if (!reasonMatch) return 'unspecified'
77+
// 格式1: ### Revocation Reason\n\nCompromised (GitHub issue 模板格式)
78+
const match1 = body.match(/###\s*Revocation\s*Reason\s*\n+(\w+)/i)
79+
if (match1) {
80+
const reason = match1[1].toLowerCase()
81+
return mapRevocationReason(reason)
82+
}
83+
84+
// 格式2: reason: xxx 或 reason:xxx
85+
const match2 = body.match(/reason[:]\s*(\w+)/i)
86+
if (match2) {
87+
const reason = match2[1].toLowerCase()
88+
return mapRevocationReason(reason)
89+
}
7990

80-
const reason = reasonMatch[1].toLowerCase()
91+
return 'unspecified'
92+
}
8193

82-
// 映射到标准 CRL 原因代码
94+
/**
95+
* 映射吊销原因到标准 CRL 原因代码
96+
*/
97+
function mapRevocationReason (reason) {
8398
const reasonMap = {
8499
compromised: 'keyCompromise',
85100
lost: 'keyCompromise',
86101
superseded: 'superseded',
87102
other: 'unspecified'
88103
}
89-
90104
return reasonMap[reason] || 'unspecified'
91105
}
92106

0 commit comments

Comments
 (0)