Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ lint error when query is used both as check and data query #1380

Merged
merged 3 commits into from
Jul 23, 2024

Conversation

imilchev
Copy link
Member

No description provided.

Copy link
Contributor

github-actions bot commented Jul 22, 2024

Test Results

  1 files   24 suites   20s ⏱️
395 tests 394 ✅ 1 💤 0 ❌
396 runs  395 ✅ 1 💤 0 ❌

Results for commit f8db0d1.

♻️ This comment has been updated with latest results.

This comment has been minimized.

@imilchev imilchev marked this pull request as draft July 22, 2024 15:33
@@ -414,6 +417,20 @@ func lintFile(file string) (*Results, error) {
uid := check.Uid
updateAssignedQueries(check, assignedQueries, globalQueriesByUid)

checks[check.CodeId] = struct{}{}
if _, ok := dataQueries[check.CodeId]; ok {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point in the code, CodeId isn't set. If we move this logic to outside of this function, the file context is missing...

If we want to implement this error, we will need to use this in combination with the ocmpiled bundle map. The issue is that the bundlemap indexes queries by MRN, but this struct has only UIDs. There is no easy way to match which query gets which mrn/codeid

@@ -414,6 +417,20 @@ func lintFile(file string) (*Results, error) {
uid := check.Uid
updateAssignedQueries(check, assignedQueries, globalQueriesByUid)

checks[check.Uid] = struct{}{}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only check by uid since this is under user control. It is still possible to cause weirdness when the MQL is identical for a query and a check but that's a bug in the resolved policy. It's not something to be caught by the linter

@imilchev imilchev marked this pull request as ready for review July 23, 2024 09:54
@@ -34,6 +34,7 @@ const (
queryTitle = "query-name"
queryUidUnique = "query-uid-unique"
queryUnassigned = "query-unassigned"
queryUsedAsDifferentTypes = "query-used-as-different-types"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you need to update the LinterRules var with this entry too so that it shows in the sarif report

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point! I missed that

Signed-off-by: Ivan Milchev <[email protected]>
@imilchev imilchev merged commit 72a6694 into main Jul 23, 2024
14 checks passed
@imilchev imilchev deleted the ivan/lint-query-types branch July 23, 2024 10:10
@github-actions github-actions bot locked and limited conversation to collaborators Jul 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants