Skip to content

Commit

Permalink
Merge pull request #61 from Omegapoint/feature/update-config
Browse files Browse the repository at this point in the history
delete validaition of schema
  • Loading branch information
linnea-oxenwaldt authored Mar 12, 2024
2 parents 5be765f + 05f2e45 commit 7eafcfa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 105 deletions.
45 changes: 14 additions & 31 deletions src/cydigConfig.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,29 @@
{
"teamName": "Test-GitHub",
"teamName": "CyDig",
"usingAzure": true,
"threatModeling": {
"date": "2023-09-07",
"boardsTag": "TM"
"date": "2024-01-01",
"boardsTag": "TM"
},
"pentest": {
"date": "2023-09-07",
"boardsTag": "PT"
},
"github": {
"usingRepos": true
"date": "2023-01-01",
"boardsTag": "PT"
},
"azureDevOps": {
"usingRepos": false,
"repos": {
"username": "firstname.lastname (usually)"
},
"usingBoards": true,
"boards": {
"nameOfBoard": "not specified"
},
"organizationName": "CyDig",
"projectName": "CyDig"
"usingBoards": true,
"boards": {
"organizationName": "CyDig",
"projectName": "CyDig",
"nameOfBoard": "not specified"
}
},
"scaTool": {
"nameOfTool": "name-of-tool",
"owaspDependencyCheck": {
"reportPath": "Reports/dependency-check-report.csv",
"csvPath": "not specified"
}
"nameOfTool": "OWASP"
},
"sastTool": {
"nameOfTool": "name-of-tool",
"semgrep": {
"reportPath": "semgrep-json.json"
}
"nameOfTool": "CodeQL"
},
"codeQualityTool": {
"nameOfTool": "name-of-tool"
},
"reposToExclude": {
"nameOfRepos": "not-specified"
"nameOfTool": "not specified"
}
}
8 changes: 4 additions & 4 deletions src/lib/BodyBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class BodyBuilder {
const cqNumberOfSeverity5: string | undefined = process.env?.CQnumberOfSeverity5;

const sastNumberOfSeverity1: string | undefined = process.env?.SASTnumberOfSeverity1;
const sastNumberOfSeverity2: string | undefined = process.env.SASTnumberOfSeverity2;
const sastNumberOfSeverity2: string | undefined = process.env?.SASTnumberOfSeverity2;
const sastNumberOfSeverity3: string | undefined = process.env?.SASTnumberOfSeverity3;

const tmNumberOfActiveTickets: string | undefined = process.env?.tmNumberOfActiveTickets
Expand All @@ -47,9 +47,9 @@ export class BodyBuilder {
const ptNumberOfActiveTickets: string | undefined = process.env?.ptNumberOfActiveTickets;
const ptNumberOfClosedTickets: string | undefined = process.env?.ptNumberOfClosedTickets;

const numUserInProdSeverity1: string | undefined = process.env.numUserInProdSeverity1;
const numUserInProdSeverity2: string | undefined = process.env.numUserInProdSeverity2;
const numUserInProdSeverity3: string | undefined = process.env.numUserInProdSeverity3;
const numUserInProdSeverity1: string | undefined = process.env?.numUserInProdSeverity1;
const numUserInProdSeverity2: string | undefined = process.env?.numUserInProdSeverity2;
const numUserInProdSeverity3: string | undefined = process.env?.numUserInProdSeverity3;

//For printing urls in the pipeline
const urlBody: UrlBody = new UrlBodyBuilder()
Expand Down
56 changes: 0 additions & 56 deletions src/lib/JsonService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as fs from 'fs';
import * as path from 'path';
import { CyDigConfig } from './types/CyDigConfig';
import Joi from 'joi';

export function getContentOfFile(jsonPath: string): CyDigConfig {
const jsonFilePath: string = path.resolve(
Expand All @@ -11,60 +10,5 @@ export function getContentOfFile(jsonPath: string): CyDigConfig {
const fileContent: string = fs.readFileSync(jsonFilePath, { encoding: 'utf-8' });
const cydigConfig: CyDigConfig = JSON.parse(fileContent);

validateConfig(cydigConfig);

return cydigConfig;
}

export function validateConfig(config: unknown): void {
const schema: Joi.ObjectSchema<CyDigConfig> = Joi.object({
teamName: Joi.string().required(),
usingAzure: Joi.boolean(),
threatModeling: Joi.object({
date: Joi.string(),
boardsTag: Joi.string(),
}),
pentest: Joi.object({
date: Joi.string(),
boardsTag: Joi.string(),
}),
github: Joi.object({
usingRepos: Joi.boolean(),
}),
azureDevOps: {
usingRepos: Joi.boolean(),
repos: Joi.object({
username: Joi.string(),
}),
usingBoards: Joi.boolean(),
boards: Joi.object({
nameOfBoard: Joi.string(),
}),
organizationName: Joi.string(),
projectName: Joi.string(),
},
scaTool: Joi.object({
nameOfTool: Joi.string(),
owaspDependencyCheck: Joi.object({
reportPath: Joi.string(),
csvPath: Joi.string().optional(),
}),
}),
sastTool: Joi.object({
nameOfTool: Joi.string(),
semgrep: Joi.object({
reportPath: Joi.string(),
}),
}),
codeQualityTool: Joi.object({
nameOfTool: Joi.string(),
}),
reposToExclude: Joi.object({
nameOfRepos: Joi.string().optional(),
}),
});

if (schema.validate(config).error) {
throw new Error(`${schema.validate(config).error?.message} in your CyDig Config file`);
}
}
20 changes: 6 additions & 14 deletions src/lib/types/CyDigConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,21 @@ export type CyDigConfig = {
date: string;
boardsTag: string;
};
github: {
usingRepos: boolean;
repos: {
username: string;
};
azureDevOps: {
usingBoards: boolean;
boards: {
organizationName: string;
projectName: string;
nameOfBoard: string;
};
};
scaTool: {
nameOfTool: string;
owaspDependencyCheck: {
reportPath: string;
};
};
},
sastTool: {
nameOfTool: string;
semgrep: {
reportPath: string;
};
};
},
codeQualityTool: {
nameOfTool: string;
};
}
};

0 comments on commit 7eafcfa

Please sign in to comment.