Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
samikroy authored Jun 16, 2021
2 parents 3a4a85d + 8c0659e commit 63c6e71
Show file tree
Hide file tree
Showing 531 changed files with 35,384 additions and 17,523 deletions.
25 changes: 16 additions & 9 deletions .script/dataConnectorValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,27 @@ export async function IsValidDataConnectorSchema(filePath: string): Promise<Exit
if(!filePath.includes('Templates'))
{
let jsonFile = JSON.parse(fs.readFileSync(filePath, "utf8"));

if(isPotentialConnectorJson(jsonFile))
{
let connectorCategory = getConnectorCategory(jsonFile.dataTypes, jsonFile.instructionSteps);
let schema = JSON.parse(fs.readFileSync(".script/utils/schemas/"+ connectorCategory +"_ConnectorSchema.json", "utf8"));
isValidSchema(jsonFile, schema);
isValidId(jsonFile.id);
isValidDataType(jsonFile.dataTypes);
if(jsonFile.dataTypes[0].name.includes("Events"))
{
let connectorCategory = getConnectorCategory(jsonFile.dataTypes, jsonFile.instructionSteps);
let schema = JSON.parse(fs.readFileSync(".script/utils/schemas/"+ connectorCategory +"_ConnectorSchema.json", "utf8"));
isValidSchema(jsonFile, schema);
isValidId(jsonFile.id);
isValidDataType(jsonFile.dataTypes);

/* Disabling temporarily till we get confirmation from PM*/
// isValidFileName(filePath
isValidPermissions(jsonFile.permissions, connectorCategory);
/* Disabling temporarily till we get confirmation from PM*/
// isValidFileName(filePath
isValidPermissions(jsonFile.permissions, connectorCategory);
}
else{
console.warn(`Could not identify json file as a connector. Skipping File path: ${filePath}`)
}
}
else{
console.warn(`Could not identify json file as a connector. Skipping File path: ${filePath}`)
console.warn(`Skipping File as it is of type Events : ${filePath}`)
}
}
else{
Expand Down
34 changes: 19 additions & 15 deletions .script/idChangeValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,31 @@ const templateIdRegex:string = `(id: ${guidRegex}(.|\n)*){2}`;
const git: SimpleGit = gitP(workingDir);

export async function IsIdHasChanged(filePath: string): Promise<ExitCode> {
filePath = workingDir + '/' + filePath;
const pr = await GetPRDetails();
console.log(filePath);

if (typeof pr === "undefined") {
console.log("Azure DevOps CI for a Pull Request wasn't found. If issue persists - please open an issue");
return ExitCode.ERROR;
}

let options = [pr.targetBranch, pr.sourceBranch, filePath];
let diffSummary = await git.diff(options);
let idHasChanged = diffSummary.search(templateIdRegex) > 0;
if (idHasChanged){
throw new Error();

if(filePath.includes("Detections") || filePath.includes("Analytic Rules"))
{
filePath = workingDir + '/' + filePath;
const pr = await GetPRDetails();
console.log(filePath);

if (typeof pr === "undefined") {
console.log("Azure DevOps CI for a Pull Request wasn't found. If issue persists - please open an issue");
return ExitCode.ERROR;
}

let options = [pr.targetBranch, pr.sourceBranch, filePath];
let diffSummary = await git.diff(options);
let idHasChanged = diffSummary.search(templateIdRegex) > 0;
if (idHasChanged){
throw new Error();
}
}
return ExitCode.SUCCESS;
}

let fileKinds = ["Modified"];
let fileTypeSuffixes = ["yaml", "yml", "json"];
let filePathFolderPrefixes = ["Detections","Solutions"];
let filePathFolderPrefixes = ["Detections", "Solutions"];
let CheckOptions = {
onCheckFile: (filePath: string) => {
return IsIdHasChanged(filePath);
Expand Down
22 changes: 14 additions & 8 deletions .script/logoValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ import { isValidLogoImage } from "./utils/LogoChecker/logoImageChecker";
import { isValidLogoImageSVGContent } from "./utils/LogoChecker/logoImageSVGChecker";

export async function IsValidLogo(FileName: string): Promise<ExitCode> {
isValidLogoImage(FileName);
const svgContent: string = fs.readFileSync(FileName, { encoding: "utf8", flag: "r" });
if(svgContent != "undefined")
{
isValidLogoImageSVGContent(svgContent)
}
return ExitCode.SUCCESS;
if(FileName.includes("Logos") || FileName.includes("Data Connectors/Logo")
|| FileName.includes("Workbooks/Images/Logo")
|| FileName.includes("Workbooks/Images/Logos"))
{
isValidLogoImage(FileName);
const svgContent: string = fs.readFileSync(FileName, { encoding: "utf8", flag: "r" });
if(svgContent != "undefined")
{
isValidLogoImageSVGContent(svgContent)
}
}

return ExitCode.SUCCESS;
}

let fileTypeSuffixes;
let filePathFolderPrefixes = ["Logos"];
let filePathFolderPrefixes = ["Logos","Solutions", "Workbooks/Images/Logos"];
let fileKinds = ["Added","Modified"];
let CheckOptions = {
onCheckFile: (filePath: string) => {
Expand Down
2 changes: 1 addition & 1 deletion .script/playbooksValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function validateARMTemplateWithPlaybookResource(filePath: string, playbookARMTe
}

let fileTypeSuffixes = ["azuredeploy.json"];
let filePathFolderPrefixes = ["Playbooks"];
let filePathFolderPrefixes = ["Playbooks","Solutions"];
let fileKinds = ["Modified"];
let CheckOptions = {
onCheckFile: (filePath: string) => {
Expand Down
149 changes: 149 additions & 0 deletions .script/tests/KqlvalidationsTests/CustomTables/AADUserInfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
"Name": "AADUserInfo_CL",
"Properties": [
{
"name": "TimeGenerated",
"type": "DateTime"
},
{
"name": "Computer",
"type": "String"
},
{
"name": "RawData",
"type": "String"
},
{
"name": "BusinessPhones_s",
"type": "String"
},
{
"name": "Calendar_Owner_s",
"type": "String"
},
{
"name": "DisplayName_s",
"type": "String"
},
{
"name": "Drive_CreatedBy_s",
"type": "String"
},
{
"name": "Drive_CreatedByUser_s",
"type": "String"
},
{
"name": "Drive_LastModifiedBy_s",
"type": "String"
},
{
"name": "Drive_LastModifiedByUser_s",
"type": "String"
},
{
"name": "Drive_List_s",
"type": "String"
},
{
"name": "Drive_Owner_s",
"type": "String"
},
{
"name": "Drive_ParentReference_s",
"type": "String"
},
{
"name": "Drive_Quota_s",
"type": "String"
},
{
"name": "Drive_Root_s",
"type": "String"
},
{
"name": "Drive_SharePointIds_s",
"type": "String"
},
{
"name": "Drive_System_s",
"type": "String"
},
{
"name": "GivenName_s",
"type": "String"
},
{
"name": "Id_g",
"type": "String"
},
{
"name": "MailboxSettings_AutomaticRepliesSetting_s",
"type": "String"
},
{
"name": "MailboxSettings_Language_s",
"type": "String"
},
{
"name": "MailboxSettings_WorkingHours_s",
"type": "String"
},
{
"name": "Settings_ShiftPreferences_s",
"type": "String"
},
{
"name": "Surname_s",
"type": "String"
},
{
"name": "UserPrincipalName_s",
"type": "String"
},
{
"name": "Keys_s",
"type": "String"
},
{
"name": "Values_s",
"type": "String"
},
{
"name": "Count_d",
"type": "Real"
},
{
"name": "JobTitle_s",
"type": "String"
},
{
"name": "Mail_s",
"type": "String"
},
{
"name": "PreferredLanguage_s",
"type": "String"
},
{
"name": "MobilePhone_s",
"type": "String"
},
{
"name": "OfficeLocation_s",
"type": "String"
},
{
"name": "Type",
"type": "String"
},
{
"name": "_ResourceId",
"type": "String"
},
{
"name": "_SubscriptionId",
"type": "String"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"Name": "CognniIncidents_CL",
"Properties": [
{
"Name": "attachmentId_s",
"Type": "String"
},
{
"Name": "Computer",
"Type": "String"
},
{
"Name": "eventTime_t",
"Type": "DateTime"
},
{
"Name": "fileName_s",
"Type": "String"
},
{
"Name": "informationType_s",
"Type": "String"
},
{
"Name": "insights_s",
"Type": "String"
},
{
"Name": "internalEventId_g",
"Type": "String"
},
{
"Name": "labels_s",
"Type": "String"
},
{
"Name": "listId_g",
"Type": "String"
},
{
"Name": "listItemUniqueId_g",
"Type": "String"
},
{
"Name": "messageId_s",
"Type": "String"
},
{
"Name": "name_s",
"Type": "String"
},
{
"Name": "orgId_g",
"Type": "String"
},
{
"Name": "RawData",
"Type": "String"
},
{
"Name": "Severity",
"Type": "Int"
},
{
"Name": "siteId_g",
"Type": "String"
},
{
"Name": "sourceFileExtension_s",
"Type": "String"
},
{
"Name": "TimeGenerated",
"Type": "DateTime"
},
{
"Name": "Type",
"Type": "String"
},
{
"Name": "userId_s",
"Type": "String"
},
{
"Name": "_ResourceId",
"Type": "String"
},
{
"Name":"_SubscriptionId",
"Type":"String"
}
]
}
Loading

0 comments on commit 63c6e71

Please sign in to comment.