Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
yarn format, unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bharatkk-metron committed Jul 22, 2024
1 parent 3c9cfd7 commit a7252c2
Show file tree
Hide file tree
Showing 6 changed files with 30,741 additions and 583 deletions.
30,742 changes: 30,418 additions & 324 deletions src/steps/finding/__recordings__/fetch-findings_4198425312/recording.har

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions src/steps/finding/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { APIVersion } from '../../provider/types/common';
import { createProjectEntityIdentifier } from '../project/converter';

async function getSeverities(instanceConfig: SonarqubeIntegrationConfig) {
function getSeverities(instanceConfig: SonarqubeIntegrationConfig) {
const { severities, apiVersion } = instanceConfig;
const severitiesSet = new Set(
severities?.split(',').map((severity) => FINDINGS_SEVERITIES[severity]),
Expand All @@ -44,10 +44,12 @@ async function getSeverities(instanceConfig: SonarqubeIntegrationConfig) {
: Array.from(severitiesSet);
}

async function getFilterParams(instanceConfig: SonarqubeIntegrationConfig) {
function getFilterParams(
instanceConfig: SonarqubeIntegrationConfig,
): NodeJS.Dict<string | string[]> {
const { apiVersion, status, createdInLast, types } = instanceConfig;

let filterParams;
let filterParams: NodeJS.Dict<string | string[]>;

if (apiVersion === APIVersion.V1) {
// V1 -> below 10.4 version
Expand All @@ -66,9 +68,9 @@ async function getFilterParams(instanceConfig: SonarqubeIntegrationConfig) {
issueStatuses: Array.from(statusesSet).join(','),
impactSoftwareQualities: Array.from(typesSet).join(','),
};
filterParams['createdInLast'] = createdInLast || DEFAULT_CREATED_IN_LAST;
return filterParams;
}
filterParams['createdInLast'] = createdInLast || DEFAULT_CREATED_IN_LAST;
return filterParams;
}

export async function fetchFindings({
Expand All @@ -78,8 +80,8 @@ export async function fetchFindings({
}: IntegrationStepExecutionContext<SonarqubeIntegrationConfig>) {
const client = createSonarqubeClient(instance.config, logger);

const severities = await getSeverities(instance.config);
const filerParams = await getFilterParams(instance.config);
const severities = getSeverities(instance.config);
const filterParams = getFilterParams(instance.config);

await jobState.iterateEntities(
{ _type: Entities.PROJECT._type },
Expand All @@ -96,9 +98,9 @@ export async function fetchFindings({
// by project and severity.
for (const severity of severities) {
if (instance.config.apiVersion == APIVersion.V1) {
filerParams['severities'] = severity;
filterParams['severities'] = severity;
} else {
filerParams['impactSeverities'] = severity;
filterParams['impactSeverities'] = severity;
}

await client.iterateProjectFindings(
Expand All @@ -125,7 +127,7 @@ export async function fetchFindings({
);
}
},
{ componentKeys: project.key, ...filerParams },
{ componentKeys: project.key, ...filterParams },
);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"entries": [
{
"_id": "4c5fe1f36c23db0a0869cc48e9fb22c0",
"_id": "1ec835f51946a0b914ce8a1ef9a47e03",
"_order": 0,
"cache": {},
"request": {
Expand All @@ -35,37 +35,32 @@
"name": "accept-encoding",
"value": "gzip,deflate"
},
{
"_fromType": "array",
"name": "connection",
"value": "close"
},
{
"name": "host",
"value": "127.0.0.1:9000"
"value": "localhost:9000"
}
],
"headersSize": 308,
"headersSize": 309,
"httpVersion": "HTTP/1.1",
"method": "GET",
"queryString": [
{
"name": "p",
"name": "pageIndex",
"value": "1"
},
{
"name": "ps",
"name": "pageSize",
"value": "100"
}
],
"url": "http://127.0.0.1:9000/api/user_groups/search?p=1&ps=100"
"url": "http://localhost:9000/api/v2/authorizations/groups?pageIndex=1&pageSize=100"
},
"response": {
"bodySize": 298,
"bodySize": 362,
"content": {
"mimeType": "application/json",
"size": 298,
"text": "{\"paging\":{\"pageIndex\":1,\"pageSize\":100,\"total\":2},\"groups\":[{\"name\":\"sonar-administrators\",\"description\":\"System administrators\",\"membersCount\":1,\"default\":false,\"managed\":false},{\"name\":\"sonar-users\",\"description\":\"Every authenticated user automatically belongs to this group\",\"membersCount\":1,\"default\":true,\"managed\":false}]}"
"size": 362,
"text": "{\"groups\":[{\"id\":\"749fee46-a864-496d-9f0b-51c2965ad89f\",\"name\":\"sonar-administrators\",\"description\":\"System administrators\",\"managed\":false,\"default\":false},{\"id\":\"20921e4e-31dd-4c7c-9396-c9fea7fef3de\",\"name\":\"sonar-users\",\"description\":\"Every authenticated user automatically belongs to this group\",\"managed\":false,\"default\":true}],\"page\":{\"pageIndex\":1,\"pageSize\":100,\"total\":2}}"
},
"cookies": [],
"headers": [
Expand All @@ -83,19 +78,31 @@
},
{
"name": "content-security-policy",
"value": "default-src 'self'; base-uri 'none'; connect-src 'self' http: https:; img-src * data: blob:; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'none'"
"value": "default-src 'self'; base-uri 'none'; connect-src 'self' http: https:; font-src 'self' data:; img-src * data: blob:; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'none'"
},
{
"name": "x-content-security-policy",
"value": "default-src 'self'; base-uri 'none'; connect-src 'self' http: https:; img-src * data: blob:; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'none'"
"value": "default-src 'self'; base-uri 'none'; connect-src 'self' http: https:; font-src 'self' data:; img-src * data: blob:; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'none'"
},
{
"name": "x-webkit-csp",
"value": "default-src 'self'; base-uri 'none'; connect-src 'self' http: https:; img-src * data: blob:; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'none'"
"value": "default-src 'self'; base-uri 'none'; connect-src 'self' http: https:; font-src 'self' data:; img-src * data: blob:; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'none'"
},
{
"name": "cross-origin-embedder-policy",
"value": "require-corp"
},
{
"name": "cross-origin-opener-policy",
"value": "same-origin"
},
{
"name": "cross-origin-resource-policy",
"value": "same-origin"
},
{
"name": "cache-control",
"value": "no-cache, no-store, must-revalidate"
"name": "sonarqube-authentication-token-expiration",
"value": "2024-08-17T00:00:00+0000"
},
{
"name": "vary",
Expand All @@ -107,33 +114,33 @@
},
{
"name": "date",
"value": "Fri, 12 Apr 2024 14:45:31 GMT"
"value": "Mon, 22 Jul 2024 09:58:43 GMT"
},
{
"name": "connection",
"value": "close"
}
],
"headersSize": 930,
"headersSize": 1144,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2024-04-12T14:45:31.186Z",
"time": 52,
"startedDateTime": "2024-07-22T09:58:43.409Z",
"time": 18,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 52
"wait": 18
}
},
{
"_id": "275a1f10e4acd99c9d73a5b7ea3729c9",
"_id": "25bcff3d3b4050ed35366bbedf3620fb",
"_order": 0,
"cache": {},
"request": {
Expand All @@ -160,37 +167,32 @@
"name": "accept-encoding",
"value": "gzip,deflate"
},
{
"_fromType": "array",
"name": "connection",
"value": "close"
},
{
"name": "host",
"value": "127.0.0.1:9000"
"value": "localhost:9000"
}
],
"headersSize": 308,
"headersSize": 309,
"httpVersion": "HTTP/1.1",
"method": "GET",
"queryString": [
{
"name": "p",
"name": "pageIndex",
"value": "2"
},
{
"name": "ps",
"name": "pageSize",
"value": "100"
}
],
"url": "http://127.0.0.1:9000/api/user_groups/search?p=2&ps=100"
"url": "http://localhost:9000/api/v2/authorizations/groups?pageIndex=2&pageSize=100"
},
"response": {
"bodySize": 126,
"bodySize": 118,
"content": {
"mimeType": "application/json",
"size": 126,
"text": "{\"paging\":{\"pageIndex\":2,\"pageSize\":100,\"total\":2},\"groups\":[]}"
"size": 118,
"text": "{\"groups\":[],\"page\":{\"pageIndex\":2,\"pageSize\":100,\"total\":2}}"
},
"cookies": [],
"headers": [
Expand All @@ -208,19 +210,31 @@
},
{
"name": "content-security-policy",
"value": "default-src 'self'; base-uri 'none'; connect-src 'self' http: https:; img-src * data: blob:; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'none'"
"value": "default-src 'self'; base-uri 'none'; connect-src 'self' http: https:; font-src 'self' data:; img-src * data: blob:; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'none'"
},
{
"name": "x-content-security-policy",
"value": "default-src 'self'; base-uri 'none'; connect-src 'self' http: https:; img-src * data: blob:; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'none'"
"value": "default-src 'self'; base-uri 'none'; connect-src 'self' http: https:; font-src 'self' data:; img-src * data: blob:; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'none'"
},
{
"name": "x-webkit-csp",
"value": "default-src 'self'; base-uri 'none'; connect-src 'self' http: https:; img-src * data: blob:; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'none'"
"value": "default-src 'self'; base-uri 'none'; connect-src 'self' http: https:; font-src 'self' data:; img-src * data: blob:; object-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; worker-src 'none'"
},
{
"name": "cross-origin-embedder-policy",
"value": "require-corp"
},
{
"name": "cross-origin-opener-policy",
"value": "same-origin"
},
{
"name": "cross-origin-resource-policy",
"value": "same-origin"
},
{
"name": "cache-control",
"value": "no-cache, no-store, must-revalidate"
"name": "sonarqube-authentication-token-expiration",
"value": "2024-08-17T00:00:00+0000"
},
{
"name": "vary",
Expand All @@ -232,29 +246,29 @@
},
{
"name": "date",
"value": "Fri, 12 Apr 2024 14:45:31 GMT"
"value": "Mon, 22 Jul 2024 09:58:43 GMT"
},
{
"name": "connection",
"value": "close"
}
],
"headersSize": 930,
"headersSize": 1144,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2024-04-12T14:45:31.260Z",
"time": 24,
"startedDateTime": "2024-07-22T09:58:43.438Z",
"time": 5,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 24
"wait": 5
}
}
],
Expand Down
Loading

0 comments on commit a7252c2

Please sign in to comment.