From 59d53ab3cc2063867e3efee51e33f532af18fd35 Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Thu, 3 Jun 2021 19:36:54 +0530 Subject: [PATCH 01/19] Fixes for PR Validations --- .script/logoValidator.ts | 2 +- .script/playbooksValidator.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.script/logoValidator.ts b/.script/logoValidator.ts index 5b4b75ffbd..3b1608bcd0 100644 --- a/.script/logoValidator.ts +++ b/.script/logoValidator.ts @@ -16,7 +16,7 @@ export async function IsValidLogo(FileName: string): Promise { } let fileTypeSuffixes; -let filePathFolderPrefixes = ["Logos"]; +let filePathFolderPrefixes = ["Logos","Data Connectors/Logo"]; let fileKinds = ["Added","Modified"]; let CheckOptions = { onCheckFile: (filePath: string) => { diff --git a/.script/playbooksValidator.ts b/.script/playbooksValidator.ts index b1c64f27b2..c5fe941321 100644 --- a/.script/playbooksValidator.ts +++ b/.script/playbooksValidator.ts @@ -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) => { From d823d05f26ab763a5e8bf49f254835488adba6a6 Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Thu, 3 Jun 2021 20:29:10 +0530 Subject: [PATCH 02/19] Added check for Data COnnectors/ Logo folder --- .script/logoValidator.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.script/logoValidator.ts b/.script/logoValidator.ts index 3b1608bcd0..04c531328a 100644 --- a/.script/logoValidator.ts +++ b/.script/logoValidator.ts @@ -6,17 +6,21 @@ import { isValidLogoImage } from "./utils/LogoChecker/logoImageChecker"; import { isValidLogoImageSVGContent } from "./utils/LogoChecker/logoImageSVGChecker"; export async function IsValidLogo(FileName: string): Promise { - isValidLogoImage(FileName); - const svgContent: string = fs.readFileSync(FileName, { encoding: "utf8", flag: "r" }); - if(svgContent != "undefined") - { - isValidLogoImageSVGContent(svgContent) - } - return ExitCode.SUCCESS; + if(FileName.indexOf("Logos") || FileName.indexOf("Data Connectors/Logo") != -1) + { + 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","Data Connectors/Logo"]; +let filePathFolderPrefixes = ["Logos","Logo"]; let fileKinds = ["Added","Modified"]; let CheckOptions = { onCheckFile: (filePath: string) => { From 17fa95c0b9b7cad404b6149d2c8a76442a251bff Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 00:00:14 +0530 Subject: [PATCH 03/19] Updated folder path for solutions --- .script/idChangeValidator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.script/idChangeValidator.ts b/.script/idChangeValidator.ts index 9f95745ba0..2679634917 100644 --- a/.script/idChangeValidator.ts +++ b/.script/idChangeValidator.ts @@ -30,7 +30,7 @@ export async function IsIdHasChanged(filePath: string): Promise { let fileKinds = ["Modified"]; let fileTypeSuffixes = ["yaml", "yml", "json"]; -let filePathFolderPrefixes = ["Detections","Solutions"]; +let filePathFolderPrefixes = ["Detections","Analytic Rules"]; let CheckOptions = { onCheckFile: (filePath: string) => { return IsIdHasChanged(filePath); From c07c1b6585bba28ed5ff1467726c415902e9c170 Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 00:14:06 +0530 Subject: [PATCH 04/19] Updated logo validation condition --- .script/logoValidator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.script/logoValidator.ts b/.script/logoValidator.ts index 04c531328a..6a4ee8d322 100644 --- a/.script/logoValidator.ts +++ b/.script/logoValidator.ts @@ -6,7 +6,7 @@ import { isValidLogoImage } from "./utils/LogoChecker/logoImageChecker"; import { isValidLogoImageSVGContent } from "./utils/LogoChecker/logoImageSVGChecker"; export async function IsValidLogo(FileName: string): Promise { - if(FileName.indexOf("Logos") || FileName.indexOf("Data Connectors/Logo") != -1) + if(FileName.indexOf("Logos") != -1 || FileName.indexOf("Data Connectors/Logo") != -1) { isValidLogoImage(FileName); const svgContent: string = fs.readFileSync(FileName, { encoding: "utf8", flag: "r" }); From 06c32e1dad4e25e2c2f6c51dd4431f3a16ca6cfc Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 00:38:09 +0530 Subject: [PATCH 05/19] Updated logo validator --- .script/logoValidator.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.script/logoValidator.ts b/.script/logoValidator.ts index 6a4ee8d322..1c3496a0f2 100644 --- a/.script/logoValidator.ts +++ b/.script/logoValidator.ts @@ -4,6 +4,7 @@ import { ExitCode } from "./utils/exitCode"; import * as logger from "./utils/logger"; import { isValidLogoImage } from "./utils/LogoChecker/logoImageChecker"; import { isValidLogoImageSVGContent } from "./utils/LogoChecker/logoImageSVGChecker"; +import { LogoValidationError } from "./utils/validationError"; export async function IsValidLogo(FileName: string): Promise { if(FileName.indexOf("Logos") != -1 || FileName.indexOf("Data Connectors/Logo") != -1) @@ -15,6 +16,10 @@ export async function IsValidLogo(FileName: string): Promise { isValidLogoImageSVGContent(svgContent) } } + else + { + throw new LogoValidationError(`Logo must be in Logos or Logo folder ` + FileName); + } return ExitCode.SUCCESS; } From af93075a06a290802d494b45ee8ca65df88a19f5 Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 00:47:09 +0530 Subject: [PATCH 06/19] updates --- .script/logoValidator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.script/logoValidator.ts b/.script/logoValidator.ts index 1c3496a0f2..fcc25bd12f 100644 --- a/.script/logoValidator.ts +++ b/.script/logoValidator.ts @@ -25,7 +25,7 @@ export async function IsValidLogo(FileName: string): Promise { } let fileTypeSuffixes; -let filePathFolderPrefixes = ["Logos","Logo"]; +let filePathFolderPrefixes = ["Logos","Solutions"]; let fileKinds = ["Added","Modified"]; let CheckOptions = { onCheckFile: (filePath: string) => { From 2ec59c3b3e0ded4afcc5a36c3e1bfd7c55121fde Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 01:05:37 +0530 Subject: [PATCH 07/19] updated logo file check --- .script/logoValidator.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.script/logoValidator.ts b/.script/logoValidator.ts index fcc25bd12f..f40f93e555 100644 --- a/.script/logoValidator.ts +++ b/.script/logoValidator.ts @@ -7,7 +7,7 @@ import { isValidLogoImageSVGContent } from "./utils/LogoChecker/logoImageSVGChec import { LogoValidationError } from "./utils/validationError"; export async function IsValidLogo(FileName: string): Promise { - if(FileName.indexOf("Logos") != -1 || FileName.indexOf("Data Connectors/Logo") != -1) + if(FileName.includes("Logos") || FileName.includes("Data Connectors/Logo")) { isValidLogoImage(FileName); const svgContent: string = fs.readFileSync(FileName, { encoding: "utf8", flag: "r" }); @@ -16,10 +16,6 @@ export async function IsValidLogo(FileName: string): Promise { isValidLogoImageSVGContent(svgContent) } } - else - { - throw new LogoValidationError(`Logo must be in Logos or Logo folder ` + FileName); - } return ExitCode.SUCCESS; } From 041365ba26b1122dc28ce22e1f7ef454c8b1049e Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 01:08:34 +0530 Subject: [PATCH 08/19] Removed unwanted import --- .script/logoValidator.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/.script/logoValidator.ts b/.script/logoValidator.ts index f40f93e555..285aa9e2a6 100644 --- a/.script/logoValidator.ts +++ b/.script/logoValidator.ts @@ -4,7 +4,6 @@ import { ExitCode } from "./utils/exitCode"; import * as logger from "./utils/logger"; import { isValidLogoImage } from "./utils/LogoChecker/logoImageChecker"; import { isValidLogoImageSVGContent } from "./utils/LogoChecker/logoImageSVGChecker"; -import { LogoValidationError } from "./utils/validationError"; export async function IsValidLogo(FileName: string): Promise { if(FileName.includes("Logos") || FileName.includes("Data Connectors/Logo")) From 83317a8a7da3005ceddc362b6d0ccccb9b763265 Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 01:12:46 +0530 Subject: [PATCH 09/19] Updated idchange validator condition --- .script/idChangeValidator.ts | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/.script/idChangeValidator.ts b/.script/idChangeValidator.ts index 2679634917..c3a9e2c59e 100644 --- a/.script/idChangeValidator.ts +++ b/.script/idChangeValidator.ts @@ -10,27 +10,31 @@ const templateIdRegex:string = `(id: ${guidRegex}(.|\n)*){2}`; const git: SimpleGit = gitP(workingDir); export async function IsIdHasChanged(filePath: string): Promise { - 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","Analytic Rules"]; +let filePathFolderPrefixes = ["Detections", "Solutions"]; let CheckOptions = { onCheckFile: (filePath: string) => { return IsIdHasChanged(filePath); From 3d3d89eb229cd91c19091b57970cc22afbda4109 Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 12:11:08 +0530 Subject: [PATCH 10/19] Handle Event type connectors --- .script/dataConnectorValidator.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.script/dataConnectorValidator.ts b/.script/dataConnectorValidator.ts index 3c9929f1b6..2782f05b58 100644 --- a/.script/dataConnectorValidator.ts +++ b/.script/dataConnectorValidator.ts @@ -13,20 +13,27 @@ export async function IsValidDataConnectorSchema(filePath: string): Promise Date: Fri, 4 Jun 2021 16:54:18 +0530 Subject: [PATCH 11/19] Extended validation to Solutions folder --- .../DetectionsYamlFilesTestData.cs | 10 +- .../ExplorationQueriesYamlFilesTestData.cs | 10 +- .../NonAsciiValidationsTests/FilesTestData.cs | 103 +++++++++--------- .../HuntingQueriesYamlFilesTestData.cs | 10 +- .../ParsersYamlFilesTestData.cs | 10 +- 5 files changed, 73 insertions(+), 70 deletions(-) diff --git a/.script/tests/NonAsciiValidationsTests/DetectionsYamlFilesTestData.cs b/.script/tests/NonAsciiValidationsTests/DetectionsYamlFilesTestData.cs index 4582207530..e27a2bd601 100644 --- a/.script/tests/NonAsciiValidationsTests/DetectionsYamlFilesTestData.cs +++ b/.script/tests/NonAsciiValidationsTests/DetectionsYamlFilesTestData.cs @@ -7,9 +7,9 @@ using System.Text; namespace NonAsciiValidations.Tests { - public class DetectionsYamlFilesTestData : FilesTestData - { - protected override string FolderName => "Detections"; - protected override string FileExtension => "*.yaml"; - } + public class DetectionsYamlFilesTestData : FilesTestData + { + protected override string[] FolderName => new string[2] { "Detections", "Solutions" }; + protected override string FileExtension => "*.yaml"; + } } diff --git a/.script/tests/NonAsciiValidationsTests/ExplorationQueriesYamlFilesTestData.cs b/.script/tests/NonAsciiValidationsTests/ExplorationQueriesYamlFilesTestData.cs index 85e2ba5843..508c6f7caa 100644 --- a/.script/tests/NonAsciiValidationsTests/ExplorationQueriesYamlFilesTestData.cs +++ b/.script/tests/NonAsciiValidationsTests/ExplorationQueriesYamlFilesTestData.cs @@ -7,9 +7,9 @@ using System.Text; namespace NonAsciiValidations.Tests { - public class ExplorationQueriesYamlFilesTestData : FilesTestData - { - protected override string FolderName => "Exploration Queries"; - protected override string FileExtension => "*.yaml"; - } + public class ExplorationQueriesYamlFilesTestData : FilesTestData + { + protected override string[] FolderName => new string[2] { "Exploration Queries", "Solutions" }; + protected override string FileExtension => "*.yaml"; + } } diff --git a/.script/tests/NonAsciiValidationsTests/FilesTestData.cs b/.script/tests/NonAsciiValidationsTests/FilesTestData.cs index 3184d7c1f9..099b274f7c 100644 --- a/.script/tests/NonAsciiValidationsTests/FilesTestData.cs +++ b/.script/tests/NonAsciiValidationsTests/FilesTestData.cs @@ -7,59 +7,62 @@ using System.Text; namespace NonAsciiValidations.Tests { - public abstract class FilesTestData : TheoryData - { - public FilesTestData() - { - string rootPath = GetFilesRootPath(); - var files = Directory.GetFiles(rootPath, FileExtension, SearchOption.AllDirectories).ToList(); - files.ForEach(f => Add(Path.GetFileName(f),f)); - } + public abstract class FilesTestData : TheoryData + { + public FilesTestData() + { + foreach (string folder in FolderName) + { + string rootPath = GetFilesRootPath(folder); + var files = Directory.GetFiles(rootPath, FileExtension, SearchOption.AllDirectories).ToList(); + files.ForEach(f => Add(Path.GetFileName(f), f)); + } + } - private string GetFilesRootPath() - { - var rootDir = Directory.CreateDirectory(GetAssemblyDirectory()); - var testFolderDepth = 6; - for (int i = 0; i < testFolderDepth; i++) - { - rootDir = rootDir.Parent; - } - var detectionPath = Path.Combine(rootDir.FullName, FolderName); - return detectionPath; - } + private string GetFilesRootPath(string folderName) + { + var rootDir = Directory.CreateDirectory(GetAssemblyDirectory()); + var testFolderDepth = 6; + for (int i = 0; i < testFolderDepth; i++) + { + rootDir = rootDir.Parent; + } + var detectionPath = Path.Combine(rootDir.FullName, folderName); + return detectionPath; + } - public string GetCustomTablesPath() - { - var rootDir = Directory.CreateDirectory(GetAssemblyDirectory()); - var testFolderDepth = 3; - for (int i = 0; i < testFolderDepth; i++) - { - rootDir = rootDir.Parent; - } - var rootPath = Path.Combine(rootDir.FullName, FolderName); - return rootPath; - } + public string GetCustomTablesPath(string folderName) + { + var rootDir = Directory.CreateDirectory(GetAssemblyDirectory()); + var testFolderDepth = 3; + for (int i = 0; i < testFolderDepth; i++) + { + rootDir = rootDir.Parent; + } + var rootPath = Path.Combine(rootDir.FullName, folderName); + return rootPath; + } - protected abstract string FolderName {get;} - protected abstract string FileExtension { get; } + protected abstract string[] FolderName { get; } + protected abstract string FileExtension { get; } - public static string GetSkipTemplatesPath() - { - var rootDir = Directory.CreateDirectory(GetAssemblyDirectory()); - var testFolderDepth = 3; - for (int i = 0; i < testFolderDepth; i++) - { - rootDir = rootDir.Parent; - } - return rootDir.FullName; - } + public static string GetSkipTemplatesPath() + { + var rootDir = Directory.CreateDirectory(GetAssemblyDirectory()); + var testFolderDepth = 3; + for (int i = 0; i < testFolderDepth; i++) + { + rootDir = rootDir.Parent; + } + return rootDir.FullName; + } - private static string GetAssemblyDirectory() - { - string codeBase = Assembly.GetExecutingAssembly().CodeBase; - UriBuilder uri = new UriBuilder(codeBase); - string path = Uri.UnescapeDataString(uri.Path); - return Path.GetDirectoryName(path); - } - } + private static string GetAssemblyDirectory() + { + string codeBase = Assembly.GetExecutingAssembly().CodeBase; + UriBuilder uri = new UriBuilder(codeBase); + string path = Uri.UnescapeDataString(uri.Path); + return Path.GetDirectoryName(path); + } + } } diff --git a/.script/tests/NonAsciiValidationsTests/HuntingQueriesYamlFilesTestData.cs b/.script/tests/NonAsciiValidationsTests/HuntingQueriesYamlFilesTestData.cs index 6d2d1270f3..b945295c6f 100644 --- a/.script/tests/NonAsciiValidationsTests/HuntingQueriesYamlFilesTestData.cs +++ b/.script/tests/NonAsciiValidationsTests/HuntingQueriesYamlFilesTestData.cs @@ -7,9 +7,9 @@ using System.Text; namespace NonAsciiValidations.Tests { - public class HuntingQueriesYamlFilesTestData : FilesTestData - { - protected override string FolderName => "Hunting Queries"; - protected override string FileExtension => "*.yaml"; - } + public class HuntingQueriesYamlFilesTestData : FilesTestData + { + protected override string[] FolderName => new string[2] { "Hunting Queries", "Solutions" }; + protected override string FileExtension => "*.yaml"; + } } diff --git a/.script/tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs b/.script/tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs index 793bb5ac6c..055c14afc1 100644 --- a/.script/tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs +++ b/.script/tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs @@ -7,9 +7,9 @@ using System.Text; namespace NonAsciiValidations.Tests { - public class ParsersYamlFilesTestData : FilesTestData - { - protected override string FolderName => "Parsers"; - protected override string FileExtension => "*.*"; - } + public class ParsersYamlFilesTestData : FilesTestData + { + protected override string[] FolderName => new string[2] { "Parsers", " Solutions" }; + protected override string FileExtension => "*.*"; + } } From 59e992e434946407e297b5c55258913768eec64c Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 17:10:24 +0530 Subject: [PATCH 12/19] Handled scenario for Validations in Parsers --- .../tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.script/tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs b/.script/tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs index 055c14afc1..c771cdffc6 100644 --- a/.script/tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs +++ b/.script/tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs @@ -9,7 +9,7 @@ namespace NonAsciiValidations.Tests { public class ParsersYamlFilesTestData : FilesTestData { - protected override string[] FolderName => new string[2] { "Parsers", " Solutions" }; + protected override string[] FolderName => new string[1] { "Parsers" }; protected override string FileExtension => "*.*"; } } From 2875e51a4b700032a6b6b13837220fbeeaf57cfe Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 17:17:13 +0530 Subject: [PATCH 13/19] Handled validation for parsers under solutions folder --- .../NonAsciiValidationsTests.cs | 69 ++++++++++--------- .../ParsersYamlFilesTestData.cs | 2 +- .vscode/launch.json | 43 ++++++++++++ .vscode/tasks.json | 42 +++++++++++ .../SampleDataIngestTool/SampleDataPath.cs | 4 +- .../SampleDataIngestTool/config.txt | 12 ++-- 6 files changed, 130 insertions(+), 42 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.script/tests/NonAsciiValidationsTests/NonAsciiValidationsTests.cs b/.script/tests/NonAsciiValidationsTests/NonAsciiValidationsTests.cs index 7cd632c66f..67fe8f5be2 100644 --- a/.script/tests/NonAsciiValidationsTests/NonAsciiValidationsTests.cs +++ b/.script/tests/NonAsciiValidationsTests/NonAsciiValidationsTests.cs @@ -8,43 +8,46 @@ using Xunit.Abstractions; namespace NonAsciiValidations.Tests { - public class NonAsciiValidationsTests - { - [Theory] - [ClassData(typeof(HuntingQueriesYamlFilesTestData))] - public void Validate_Hunting_HaveOnlyAsciiChars(string huntingYamlFileName,string yamlFullPath) - { - ValidateOnlyAscii(yamlFullPath, huntingYamlFileName); - } + public class NonAsciiValidationsTests + { + [Theory] + [ClassData(typeof(HuntingQueriesYamlFilesTestData))] + public void Validate_Hunting_HaveOnlyAsciiChars(string huntingYamlFileName, string yamlFullPath) + { + ValidateOnlyAscii(yamlFullPath, huntingYamlFileName); + } - [Theory] - [ClassData(typeof(ParsersYamlFilesTestData))] - public void Validate_Parsers_HaveOnlyAsciiChars(string parserYamlFileName, string yamlFullPath) - { - ValidateOnlyAscii(yamlFullPath, parserYamlFileName); - } + [Theory] + [ClassData(typeof(ParsersYamlFilesTestData))] + public void Validate_Parsers_HaveOnlyAsciiChars(string parserYamlFileName, string yamlFullPath) + { + if (yamlFullPath.Contains("Parsers")) + { + ValidateOnlyAscii(yamlFullPath, parserYamlFileName); + } + } - [Theory] - [ClassData(typeof(ExplorationQueriesYamlFilesTestData))] - public void Validate_ExplorationQueries_HaveOnlyAsciiChars(string explorationQueryYamlFileName, string yamlFullPath) - { - ValidateOnlyAscii(yamlFullPath, explorationQueryYamlFileName); - } + [Theory] + [ClassData(typeof(ExplorationQueriesYamlFilesTestData))] + public void Validate_ExplorationQueries_HaveOnlyAsciiChars(string explorationQueryYamlFileName, string yamlFullPath) + { + ValidateOnlyAscii(yamlFullPath, explorationQueryYamlFileName); + } - [Theory] - [ClassData(typeof(DetectionsYamlFilesTestData))] - public void Validate_DetectionFile_HaveOnlyAsciiChars(string detectionsYamlFileName, string yamlFullPath) - { - ValidateOnlyAscii(yamlFullPath, detectionsYamlFileName); - } + [Theory] + [ClassData(typeof(DetectionsYamlFilesTestData))] + public void Validate_DetectionFile_HaveOnlyAsciiChars(string detectionsYamlFileName, string yamlFullPath) + { + ValidateOnlyAscii(yamlFullPath, detectionsYamlFileName); + } - private void ValidateOnlyAscii(string yamlFilePath, string yamlFileName) - { - var yaml = File.ReadAllText(yamlFilePath); - var nonAsciiCharMatch = Regex.Match(yaml, @"[^\u0000-\u007F]+"); - Assert.False(nonAsciiCharMatch.Success, $"${yamlFileName} includes the non ascii char:{nonAsciiCharMatch.Value} string index:{nonAsciiCharMatch.Index}"); - } - } + private void ValidateOnlyAscii(string yamlFilePath, string yamlFileName) + { + var yaml = File.ReadAllText(yamlFilePath); + var nonAsciiCharMatch = Regex.Match(yaml, @"[^\u0000-\u007F]+"); + Assert.False(nonAsciiCharMatch.Success, $"${yamlFileName} includes the non ascii char:{nonAsciiCharMatch.Value} string index:{nonAsciiCharMatch.Index}"); + } + } } diff --git a/.script/tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs b/.script/tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs index c771cdffc6..b8acb130f3 100644 --- a/.script/tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs +++ b/.script/tests/NonAsciiValidationsTests/ParsersYamlFilesTestData.cs @@ -9,7 +9,7 @@ namespace NonAsciiValidations.Tests { public class ParsersYamlFilesTestData : FilesTestData { - protected override string[] FolderName => new string[1] { "Parsers" }; + protected override string[] FolderName => new string[2] { "Parsers", "Solutions" }; protected override string FileExtension => "*.*"; } } diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..53464fc8fb --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,43 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/.script/tests/detectionTemplateSchemaValidation/bin/Debug/netcoreapp3.1/DetectionTemplateSchemaValidation.Tests.dll", + "args": [], + "cwd": "${workspaceFolder}/.script/tests/detectionTemplateSchemaValidation", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + }, + { + "name": "Mocha: Current File", + "type": "node", + "request": "launch", + "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", + "args": [ + "-r", + "ts-node/register", + "--file", + "${relativeFile}", + "--no-timeout" + ], + "skipFiles": [ + "/**" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000..6d467e3175 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/.script/tests/detectionTemplateSchemaValidation/DetectionTemplateSchemaValidation.Tests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/.script/tests/detectionTemplateSchemaValidation/DetectionTemplateSchemaValidation.Tests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/.script/tests/detectionTemplateSchemaValidation/DetectionTemplateSchemaValidation.Tests.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/SampleDataPath.cs b/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/SampleDataPath.cs index db4416d73f..98e7e22aae 100644 --- a/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/SampleDataPath.cs +++ b/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/SampleDataPath.cs @@ -4,7 +4,7 @@ namespace SampleDataIngestTool { public class SampleDataPath { - static readonly string subDirPath = "\\Sample Data\\Custom\\"; + static readonly string subDirPath = "C:\\Custom\\"; public SampleDataPath() { @@ -18,7 +18,7 @@ namespace SampleDataIngestTool var basePath = currentDirectory.Split(new string[] { "\\Tools" }, StringSplitOptions.None)[0]; var dirPath = basePath + subDirPath; - return dirPath; + return subDirPath; } catch (Exception ex) { diff --git a/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt b/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt index d6205e94bd..4c67a86720 100644 --- a/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt +++ b/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt @@ -1,7 +1,7 @@ { - "workspaceId": "enter_your_workspaceId_or_customerId_here", - "sharedKey": "enter_your_workspace_primary_key_here", - "clientId": "enter_your_clientId_here", - "clientSecret": "enter_your_client_secret_here", - "domain": "enter_your_app_domain_or_tenantId_here" -} \ No newline at end of file + "workspaceId": "059f037c-1b3b-42b1-bb90-e340e8c3142c", + "sharedKey": "JbqN4tGDM6gyCScT4oo0NQPW0Ap2UDbyoHHIloLo4Lr3NoKHs5MrXDmiXSOdtHQ5aPFjmkSXkKlRrBSNUtQXug==", + "clientId": "0b013e62-ed07-4bb0-a899-d6ead7c696ed", + "clientSecret": "js73iT1c7UgiBwGpS3.QD.8SI~Q8_647me", + "domain": "microsoft.com" +} From deafc17986e7cde76b71b679e9f87986cbf2bde4 Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 17:21:30 +0530 Subject: [PATCH 14/19] Delete launch.json --- .vscode/launch.json | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 53464fc8fb..0000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - // Use IntelliSense to find out which attributes exist for C# debugging - // Use hover for the description of the existing attributes - // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/.script/tests/detectionTemplateSchemaValidation/bin/Debug/netcoreapp3.1/DetectionTemplateSchemaValidation.Tests.dll", - "args": [], - "cwd": "${workspaceFolder}/.script/tests/detectionTemplateSchemaValidation", - // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console - "console": "internalConsole", - "stopAtEntry": false - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command:pickProcess}" - }, - { - "name": "Mocha: Current File", - "type": "node", - "request": "launch", - "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", - "args": [ - "-r", - "ts-node/register", - "--file", - "${relativeFile}", - "--no-timeout" - ], - "skipFiles": [ - "/**" - ] - } - ] -} \ No newline at end of file From 20e8d9041cb5cabec137617a0878a8c2ee9bb00a Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 17:22:00 +0530 Subject: [PATCH 15/19] Delete tasks.json --- .vscode/tasks.json | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 6d467e3175..0000000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "command": "dotnet", - "type": "process", - "args": [ - "build", - "${workspaceFolder}/.script/tests/detectionTemplateSchemaValidation/DetectionTemplateSchemaValidation.Tests.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "publish", - "command": "dotnet", - "type": "process", - "args": [ - "publish", - "${workspaceFolder}/.script/tests/detectionTemplateSchemaValidation/DetectionTemplateSchemaValidation.Tests.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - }, - { - "label": "watch", - "command": "dotnet", - "type": "process", - "args": [ - "watch", - "run", - "${workspaceFolder}/.script/tests/detectionTemplateSchemaValidation/DetectionTemplateSchemaValidation.Tests.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" - ], - "problemMatcher": "$msCompile" - } - ] -} \ No newline at end of file From c4801595669f8847bc42e90c9ace97886478e332 Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 17:27:58 +0530 Subject: [PATCH 16/19] Update config.txt --- .../SampleDataIngestTool/config.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt b/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt index 4c67a86720..4792be6b79 100644 --- a/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt +++ b/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt @@ -1,7 +1,7 @@ -{ - "workspaceId": "059f037c-1b3b-42b1-bb90-e340e8c3142c", - "sharedKey": "JbqN4tGDM6gyCScT4oo0NQPW0Ap2UDbyoHHIloLo4Lr3NoKHs5MrXDmiXSOdtHQ5aPFjmkSXkKlRrBSNUtQXug==", - "clientId": "0b013e62-ed07-4bb0-a899-d6ead7c696ed", - "clientSecret": "js73iT1c7UgiBwGpS3.QD.8SI~Q8_647me", - "domain": "microsoft.com" +{ + "workspaceId": "enter_your_workspaceId_or_customerId_here", + "sharedKey": "enter_your_workspace_primary_key_here", + "clientId": "enter_your_clientId_here", + "clientSecret": "enter_your_client_secret_here", + "domain": "enter_your_app_domain_or_tenantId_here" } From d6a0fbde60240118cff049044fc3bec31e36eaaa Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 17:46:51 +0530 Subject: [PATCH 17/19] Update SampleDataPath.cs --- .../SampleDataIngestTool/SampleDataPath.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/SampleDataPath.cs b/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/SampleDataPath.cs index 98e7e22aae..db4416d73f 100644 --- a/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/SampleDataPath.cs +++ b/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/SampleDataPath.cs @@ -4,7 +4,7 @@ namespace SampleDataIngestTool { public class SampleDataPath { - static readonly string subDirPath = "C:\\Custom\\"; + static readonly string subDirPath = "\\Sample Data\\Custom\\"; public SampleDataPath() { @@ -18,7 +18,7 @@ namespace SampleDataIngestTool var basePath = currentDirectory.Split(new string[] { "\\Tools" }, StringSplitOptions.None)[0]; var dirPath = basePath + subDirPath; - return subDirPath; + return dirPath; } catch (Exception ex) { From 3f151ac0d1c7bda4f538197b71546500d3cd5394 Mon Sep 17 00:00:00 2001 From: v-rucdu Date: Fri, 4 Jun 2021 17:49:33 +0530 Subject: [PATCH 18/19] Update config.txt --- Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt b/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt index 4792be6b79..580c3fc9fe 100644 --- a/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt +++ b/Tools/Sample-Data-Ingest-Tool/SampleDataIngestTool/config.txt @@ -1,4 +1,4 @@ -{ +{ "workspaceId": "enter_your_workspaceId_or_customerId_here", "sharedKey": "enter_your_workspace_primary_key_here", "clientId": "enter_your_clientId_here",