From ad85d082bd701616215cc303949184c32326fc21 Mon Sep 17 00:00:00 2001 From: Lucas Mendes Date: Mon, 18 Apr 2022 10:49:12 +0100 Subject: [PATCH 1/2] fix(script): queries validator files filtering --- .github/scripts/queries-validator/queries-validator.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/scripts/queries-validator/queries-validator.py b/.github/scripts/queries-validator/queries-validator.py index bf57177f7f1..6edb32537dc 100644 --- a/.github/scripts/queries-validator/queries-validator.py +++ b/.github/scripts/queries-validator/queries-validator.py @@ -18,7 +18,7 @@ def exit_success(): exit(0) def fetch(page=1, max_items=100): - print('Fetching PR files... #page{}'.format(page)) + print('Fetching PR #{} files... #page{}'.format(KICS_PR_NUMBER, page)) headers = {'Authorization': 'token {}'.format(KICS_GITHUB_TOKEN)} url = 'https://api.github.com/repos/checkmarx/kics/pulls/{}/files?per_page={}page={}'.format(KICS_PR_NUMBER, max_items, page) response = requests.get(url, headers=headers) @@ -35,7 +35,8 @@ def fetch_pr_files(): return exit_with_error('Failed to fetch PR files\n- status code: {}'.format(response['status'])) for obj in response['data']: - files.append(obj['filename']) + if obj['status'] != 'removed': + files.append(obj['filename']) if len(response['data']) < max_items: return files From 4306dafd4664e138aca6689cccd73711e9aea466 Mon Sep 17 00:00:00 2001 From: Lucas Mendes Date: Tue, 19 Apr 2022 09:59:49 +0100 Subject: [PATCH 2/2] fix(e2e): added validation for query name & results in json file --- e2e/utils/json.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e/utils/json.go b/e2e/utils/json.go index de273d404f8..a4cb0577059 100644 --- a/e2e/utils/json.go +++ b/e2e/utils/json.go @@ -196,6 +196,17 @@ func setFields(t *testing.T, expect, actual []string, expectFileName, actualFile for i := range actualI.Queries { actualQuery := actualI.Queries[i] expectQuery := expectI.Queries[i] + + require.Equal(t, actualQuery.QueryName, expectQuery.QueryName, + "Expected Result queries doesn't match the actual result queries [in the index: %d]."+ + "\nExpected File: 'fixtures/%s'.\nActual File: 'output/%s'.", + i, expectFileName, actualFileName) + + require.Equal(t, len(actualQuery.Files), len(expectQuery.Files), + "Expected query results doesn't match the actual query results [query: %s]."+ + "\nExpected File: 'fixtures/%s'.\nActual File: 'output/%s'.", + actualQuery.QueryName, expectFileName, actualFileName) + for j := range actualI.Queries[i].Files { actualQuery.Files[j].FileName = "" expectQuery.Files[j].FileName = ""