Skip to content

Commit

Permalink
Merge branch 'main' into NONE-eslint-services
Browse files Browse the repository at this point in the history
  • Loading branch information
atraversatlassian authored Sep 19, 2023
2 parents 51ac051 + af3cd13 commit 1fa5397
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/routes/github/repository/github-repository-get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe("GitHub Repository Search", () => {

const owner = { login: "myOrgName" };

nockSearchRepos200(`${randomString} org:myOrgName in:full_name`, {
nockSearchRepos200(`${randomString} org:myOrgName in:full_name fork:true`, {
items: [{ owner, full_name: "first", id: 1 }, { owner, full_name: "second", id: 22 }, { owner, full_name: "second", id: 333 }]
});

Expand Down Expand Up @@ -105,7 +105,7 @@ describe("GitHub Repository Search", () => {
.post(`/app/installations/${subscription.gitHubInstallationId}/access_tokens`)
.reply(200);

nockSearchRepos200(`${randomString} org:myOrgName in:full_name`, {
nockSearchRepos200(`${randomString} org:myOrgName in:full_name fork:true`, {
items: [{ full_name: "forth", id: 4444 }]
});

Expand Down Expand Up @@ -148,11 +148,11 @@ describe("GitHub Repository Search", () => {

const owner = { login: "myOrgName" };

nockSearchRepos200(`${randomString} org:myOrgName in:full_name`, {
nockSearchRepos200(`${randomString} org:myOrgName in:full_name fork:true`, {
items: [{ owner, full_name: "first", id: 1 }, { owner, full_name: "second", id: 22 }, { owner, full_name: "third", id: 333 }]
});

nockSearchRepos422(`${randomString} org:anotherOrgName in:full_name`);
nockSearchRepos422(`${randomString} org:anotherOrgName in:full_name fork:true`);

await supertest(app)
.get("/github/repository").set(
Expand Down
2 changes: 1 addition & 1 deletion src/routes/github/repository/github-repository-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const getReposBySubscriptions = async (repoName: string, subscriptions: Subscrip
createInstallationClient(subscription.gitHubInstallationId, jiraHost, metrics, logger, subscription.gitHubAppId)
]);

const searchQueryInstallationString = `${repoName} org:${orgName} in:full_name`;
const searchQueryInstallationString = `${repoName} org:${orgName} in:full_name fork:true`;

const installationSearch = await gitHubInstallationClient.searchRepositories(searchQueryInstallationString, "updated")
.then(responseInstallationSearch => {
Expand Down
4 changes: 3 additions & 1 deletion src/sync/code-scanning-alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
transformGitHubStateToJiraStatus
} from "~/src/transforms/util/github-security-alerts";
import { getCodeScanningVulnDescription } from "../transforms/transform-code-scanning-alert";
import { truncate } from "lodash";

export const getCodeScanningAlertTask = async (
parentLogger: Logger,
Expand Down Expand Up @@ -99,7 +100,8 @@ const transformCodeScanningAlert = async (
id: `c-${transformRepositoryId(repository.id, gitHubClientConfig.baseUrl)}-${alert.number}`,
updateSequenceNumber: Date.now(),
containerId: transformRepositoryId(repository.id, gitHubClientConfig.baseUrl),
displayName: alert.rule.description || alert.rule.name,
// display name cannot exceed 255 characters
displayName: truncate(alert.rule.description || alert.rule.name, { length: 254 }),
description: getCodeScanningVulnDescription(alert, identifiers, alertInstances, logger),
url: alert.html_url,
type: "sast",
Expand Down
4 changes: 3 additions & 1 deletion src/sync/dependabot-alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
transformGitHubSeverityToJiraSeverity,
transformGitHubStateToJiraStatus
} from "~/src/transforms/util/github-security-alerts";
import { truncate } from "lodash";

export const getDependabotAlertTask = async (
parentLogger: Logger,
Expand Down Expand Up @@ -96,7 +97,8 @@ const transformDependabotAlerts = async (
id: `d-${transformRepositoryId(repository.id, gitHubClientConfig.baseUrl)}-${alert.number}`,
updateSequenceNumber: Date.now(),
containerId: transformRepositoryId(repository.id, gitHubClientConfig.baseUrl),
displayName: alert.security_advisory.summary,
// display name cannot exceed 255 characters
displayName: truncate(alert.security_advisory.summary, { length: 254 }),
description: getDependabotScanningVulnDescription(alert, identifiers,logger),
url: alert.html_url,
type: "sca",
Expand Down
4 changes: 3 additions & 1 deletion src/sync/secret-scanning-alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { JiraVulnerabilityBulkSubmitData, JiraVulnerabilitySeverityEnum } from "
import { PageSizeAwareCounterCursor } from "./page-counter-cursor";
import { SecretScanningAlertResponseItem, SortDirection } from "../github/client/github-client.types";
import { getSecretScanningVulnDescription, transformGitHubStateToJiraStatus } from "../transforms/transform-secret-scanning-alert";
import { truncate } from "lodash";

export const getSecretScanningAlertTask = async (
parentLogger: Logger,
Expand Down Expand Up @@ -88,7 +89,8 @@ const transformSecretScanningAlert = async (
id: `s-${transformRepositoryId(repository.id, gitHubClientConfig.baseUrl)}-${alert.number}`,
updateSequenceNumber: Date.now(),
containerId: transformRepositoryId(repository.id, gitHubClientConfig.baseUrl),
displayName: alert.secret_type_display_name || `${alert.secret_type} secret exposed`,
// display name cannot exceed 255 characters
displayName: truncate(alert.secret_type_display_name || `${alert.secret_type} secret exposed`,{ length: 254 }),
description: getSecretScanningVulnDescription(alert, logger),
url: alert.html_url,
type: "sast",
Expand Down
3 changes: 2 additions & 1 deletion src/transforms/transform-code-scanning-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export const transformCodeScanningAlertToJiraSecurity = async (context: WebhookC
id: `c-${transformRepositoryId(repository.id, gitHubInstallationClient.baseUrl)}-${alert.number as number}`,
updateSequenceNumber: Date.now(),
containerId: transformRepositoryId(repository.id, gitHubInstallationClient.baseUrl),
displayName: alert.rule.description || alert.rule.name,
// display name cannot exceed 255 characters
displayName: truncate(alert.rule.description || alert.rule.name, { length: 254 }),
description: getCodeScanningVulnDescription(alert, identifiers, alertInstances, context.log),
url: alert.html_url,
type: "sast",
Expand Down
3 changes: 2 additions & 1 deletion src/transforms/transform-dependabot-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export const transformDependabotAlert = async (context: WebhookContext<Dependabo
id: `d-${transformRepositoryId(repository.id, githubClientConfig.baseUrl)}-${alert.number}`,
updateSequenceNumber: Date.now(),
containerId: transformRepositoryId(repository.id, githubClientConfig.baseUrl),
displayName: alert.security_advisory.summary,
// display name cannot exceed 255 characters
displayName: truncate(alert.security_advisory.summary, { length: 254 }),
description: getDependabotScanningVulnDescription(alert, identifiers, context.log),
url: alert.html_url,
type: "sca",
Expand Down
3 changes: 2 additions & 1 deletion src/transforms/transform-secret-scanning-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export const transformSecretScanningAlert = async (
id: `s-${transformRepositoryId(repository.id, githubClientConfig.baseUrl)}-${alert.number}`,
updateSequenceNumber: Date.now(),
containerId: transformRepositoryId(repository.id, githubClientConfig.baseUrl),
displayName: alert.secret_type_display_name || `${alert.secret_type} secret exposed`,
// display name cannot exceed 255 characters
displayName: truncate(alert.secret_type_display_name || `${alert.secret_type} secret exposed`, { length: 254 }),
description: getSecretScanningVulnDescription(alert, logger),
url: alert.html_url,
type: "sast",
Expand Down

0 comments on commit 1fa5397

Please sign in to comment.