Skip to content
This repository was archived by the owner on Dec 24, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 117 additions & 28 deletions example/Nullify Demo Dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,15 @@
},
"endpoint": "sast/events",
"queryParameters": {
"eventTypes": [
"new-branch-summary"
],
"githubRepositoryIdsOrQueries": [
"$repository"
],
"ownerNamesOrQueries": []
"ownerNamesOrQueries": [
"$owner"
]
},
"refId": "A"
}
Expand Down Expand Up @@ -727,7 +732,9 @@
"githubRepositoryIdsOrQueries": [
"$repository"
],
"ownerNamesOrQueries": []
"ownerNamesOrQueries": [
"$owner"
]
},
"refId": "A"
}
Expand Down Expand Up @@ -1051,12 +1058,15 @@
"queryParameters": {
"githubRepositoryIdsOrQueries": [
"$repository"
],
"ownerNamesOrQueries": [
"$owner"
]
},
"refId": "A"
}
],
"title": "Secrets Detection - First committed last 7 days",
"title": "Secrets Detection - First committed",
"transformations": [
{
"id": "filterByValue",
Expand Down Expand Up @@ -1481,25 +1491,26 @@
"queryParameters": {
"githubRepositoryIdsOrQueries": [
"$repository"
],
"ownerNamesOrQueries": [
"$owner"
]
},
"refId": "A"
}
],
"title": "Secrets Detection - Detections last 7 days",
"title": "Secrets Detection - Detections",
"transformations": [
{
"id": "filterByValue",
"options": {
"filters": [
{
"config": {
"id": "greater",
"options": {
"value": 0
}
"id": "isNotNull",
"options": {}
},
"fieldName": "finding_timeStamp"
"fieldName": "timestamp"
}
],
"match": "any",
Expand All @@ -1510,18 +1521,15 @@
"id": "groupBy",
"options": {
"fields": {
"finding_firstCommitTimestamp": {
"aggregations": []
},
"finding_timeStamp": {
"aggregations": [],
"operation": "groupby"
},
"id": {
"aggregations": [
"count"
],
"operation": "aggregate"
},
"timestamp": {
"aggregations": [],
"operation": "groupby"
}
}
}
Expand Down Expand Up @@ -1567,28 +1575,45 @@
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unitScale": true
},
"overrides": []
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Total"
},
"properties": [
{
"id": "custom.axisPlacement",
"value": "hidden"
},
{
"id": "custom.hideFrom",
"value": {
"legend": true,
"tooltip": false,
"viz": true
}
}
]
}
]
},
"gridPos": {
"h": 10,
"w": 12,
"x": 0,
"y": 40
},
"id": 5,
"id": 16,
"options": {
"barRadius": 0,
"barWidth": 0.97,
"fullHighlight": false,
"fullHighlight": true,
"groupWidth": 0.7,
"legend": {
"calcs": [],
Expand All @@ -1597,8 +1622,11 @@
"showLegend": true
},
"orientation": "auto",
"showValue": "auto",
"stacking": "none",
"showValue": "never",
"stacking": "normal",
"text": {
"valueSize": 12
},
"tooltip": {
"mode": "single",
"sort": "none"
Expand All @@ -1616,29 +1644,90 @@
"queryParameters": {
"githubRepositoryIdsOrQueries": [
"$repository"
],
"ownerNamesOrQueries": [
"$owner"
]
},
"refId": "A"
}
],
"title": "Secret Detection - By Secret Type",
"title": "Secrets - By Type and Repo",
"transformations": [
{
"id": "groupBy",
"options": {
"fields": {
"formatted_severity": {
"aggregations": [],
"operation": "groupby"
},
"id": {
"aggregations": [
"distinctCount"
"count"
],
"operation": "aggregate"
},
"language": {
"aggregations": [],
"operation": "groupby"
},
"repository": {
"aggregations": [],
"operation": "groupby"
},
"secretType": {
"aggregations": [],
"operation": "groupby"
}
}
}
},
{
"id": "groupingToMatrix",
"options": {
"columnField": "repository",
"emptyValue": "null",
"rowField": "secretType",
"valueField": "id (count)"
}
},
{
"id": "calculateField",
"options": {
"alias": "",
"mode": "reduceRow",
"reduce": {
"include": [],
"reducer": "sum"
},
"replaceFields": false
}
},
{
"id": "organize",
"options": {
"excludeByName": {
"Total": false
},
"includeByName": {},
"indexByName": {
"S1 - CRITICAL": 6,
"S2 - HIGH": 5,
"S3 - MEDIUM": 4,
"S4 - LOW": 3,
"Total": 0,
"UNKNOWN": 2,
"language\\formatted_severity": 1
},
"renameByName": {
"S4 - LOW": "",
"Total": "",
"UNKNOWN": "",
"language\\formatted_severity": "Language",
"secretType\\repository": "Repository Name"
}
}
}
],
"type": "barchart"
Expand Down Expand Up @@ -1705,6 +1794,6 @@
"timezone": "",
"title": "Nullify Demo Dashboard",
"uid": "ecf0f5c8-bf81-479a-b72f-94b5c2855d04",
"version": 3,
"version": 12,
"weekStart": ""
}
16 changes: 10 additions & 6 deletions src/api/sastEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,14 @@ export const processSastEvents = async (
events.push(...parseResult.data.events);
}

if (!parseResult.data.events || parseResult.data.events.length === 0 || !parseResult.data.nextEventId) {
if (!parseResult.data.nextEventId) {
// No more events
break;
} else if (parseResult.data.events[0].timestampUnix > range.to.unix()) {
} else if (
parseResult.data.events &&
parseResult.data.events.length > 0 &&
parseResult.data.events[0].timestampUnix < range.from.unix()
) {
// No more events required
break;
} else {
Expand Down Expand Up @@ -277,14 +281,14 @@ export const processSastEvents = async (
),
},
{
name: 'repositoryId',
name: 'repository',
type: FieldType.string,
values: events.map((event) => event.data.provider.github?.repositoryId),
values: events.map((event) => event.data.provider.github?.repositoryName),
},
{
name: 'repositoryName',
name: 'branch',
type: FieldType.string,
values: events.map((event) => event.data.provider.github?.repositoryName),
values: events.map((event) => event.data.branch),
},
{
name: 'owners',
Expand Down
16 changes: 10 additions & 6 deletions src/api/scaEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,14 @@ export const processScaEvents = async (
if (parseResult.data.events) {
events.push(...parseResult.data.events);
}
if (!parseResult.data.events || parseResult.data.events.length === 0 || !parseResult.data.nextEventId) {
if (!parseResult.data.nextEventId) {
// No more events
break;
} else if (parseResult.data.events[0].timestampUnix > range.to.unix()) {
} else if (
parseResult.data.events &&
parseResult.data.events.length > 0 &&
parseResult.data.events[0].timestampUnix < range.from.unix()
) {
// No more events required
break;
} else {
Expand Down Expand Up @@ -241,14 +245,14 @@ export const processScaEvents = async (
),
},
{
name: 'repositoryId',
name: 'repository',
type: FieldType.string,
values: events.map((event) => event.data.provider.github?.repositoryId),
values: events.map((event) => event.data.provider.github?.repositoryName),
},
{
name: 'repositoryName',
name: 'branch',
type: FieldType.string,
values: events.map((event) => event.data.provider.github?.repositoryName),
values: events.map((event) => event.data.branch),
},
{
name: 'owners',
Expand Down
5 changes: 4 additions & 1 deletion src/api/secretsCommon.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { z } from 'zod';
import { FileOwnerSchema } from './common';

export const SecretsScannerFindingEvent = z.object({
id: z.string(),
Expand All @@ -16,7 +17,9 @@ export const SecretsScannerFindingEvent = z.object({
secretHash: z.string(),
hyperlink: z.string(),
isBranchHead: z.boolean(),
branches: z.array(z.string()).nullable(),
repository: z.string(),
branch: z.string(),
firstCommitTimestamp: z.string(),
isAllowlisted: z.boolean(),
fileOwners: z.array(FileOwnerSchema).nullable(),
});
Loading