@enterprise-cmcs/macpro-security-hub-sync
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -1,3 +0,2 @@ | ||
export * from "./error-lib"; | ||
export * from "./jira-lib"; | ||
export * from "./security-hub-lib"; |
@@ -17,4 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./error-lib"), exports); | ||
__exportStar(require("./jira-lib"), exports); | ||
__exportStar(require("./security-hub-lib"), exports); |
import { IssueObject } from "jira-client"; | ||
export declare class Jira { | ||
private readonly jira; | ||
private jiraFields; | ||
jiraClosedStatuses: string[]; | ||
@@ -10,2 +11,9 @@ constructor(); | ||
closeIssue(issueKey: string): Promise<void>; | ||
mapCustomFieldNamesToIds(customJiraFields: { | ||
[fieldName: string]: any; | ||
}): Promise<{ | ||
[key: string]: [{ | ||
value: string; | ||
}]; | ||
}>; | ||
} |
@@ -35,2 +35,3 @@ "use strict"; | ||
jira; | ||
jiraFields; | ||
jiraClosedStatuses; | ||
@@ -90,2 +91,8 @@ constructor() { | ||
issue.fields.project = { key: process.env.JIRA_PROJECT }; | ||
if (issue.customJiraFields) { | ||
issue.fields = { | ||
...issue.fields, | ||
...(await this.mapCustomFieldNamesToIds(issue.customJiraFields)), | ||
}; | ||
} | ||
const response = await this.jira.addNewIssue(issue); | ||
@@ -120,3 +127,22 @@ response["webUrl"] = `https://${process.env.JIRA_HOST}/browse/${response.key}`; | ||
} | ||
async mapCustomFieldNamesToIds(customJiraFields) { | ||
if (!this.jiraFields) { | ||
try { | ||
this.jiraFields = await this.jira.listFields(); | ||
} | ||
catch (error) { | ||
throw new Error("Failed to retrieve Jira Fields"); | ||
} | ||
} | ||
const mappedFields = Object.entries(customJiraFields).reduce((acc, [fieldName, value]) => { | ||
const customField = this.jiraFields.find((field) => field.name === fieldName); | ||
if (!customField) { | ||
throw new Error(`Cannot find custom field named "${fieldName}"`); | ||
} | ||
acc[customField.id] = value; | ||
return acc; | ||
}, {}); | ||
return mappedFields; | ||
} | ||
} | ||
exports.Jira = Jira; |
@@ -6,3 +6,2 @@ "use strict"; | ||
const client_securityhub_1 = require("@aws-sdk/client-securityhub"); | ||
const error_lib_1 = require("./error-lib"); | ||
class SecurityHub { | ||
@@ -18,3 +17,3 @@ region; | ||
})); | ||
this.getAccountAlias().catch((error) => error_lib_1.Logger.logError(error)); | ||
this.getAccountAlias().catch((error) => console.log(error)); | ||
} | ||
@@ -60,3 +59,3 @@ async getAccountAlias() { | ||
catch (error) { | ||
error_lib_1.Logger.logError(error); | ||
console.log(error); | ||
return []; | ||
@@ -63,0 +62,0 @@ } |
@@ -12,3 +12,3 @@ "use strict"; | ||
constructor(options = {}) { | ||
const { region = "us-east-1", severities = ["MEDIUM", "HIGH", "CRITICAL"], customJiraFields = {}, } = options; | ||
const { region = "us-east-1", severities = ["MEDIUM", "HIGH", "CRITICAL"], customJiraFields, } = options; | ||
this.securityHub = new libs_1.SecurityHub({ region, severities }); | ||
@@ -116,4 +116,4 @@ this.region = region; | ||
], | ||
...this.customJiraFields, | ||
}, | ||
customJiraFields: this.customJiraFields, | ||
}; | ||
@@ -120,0 +120,0 @@ const newIssueInfo = await this.jira.createNewIssue(newIssueData); |
@@ -7,2 +7,6 @@ "use strict"; | ||
severities: ["CRITICAL", "HIGH"], | ||
customJiraFields: { | ||
"Working Team": [{ value: "Dev Team" }], | ||
"Product Supported": [{ value: "OneMac" }], | ||
}, | ||
}).sync(); |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "NPM module to create Jira issues for all findings in Security Hub for the current AWS account..", | ||
@@ -10,0 +10,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29247
465
16