Repository: Checkmarx/kics (language: python)

Issue:
type_has_invalid_keyword(openApi): functions must not produce multiple outputs for same inputs
### Platform
OpenApi

### Provider
N/A

### Description
running Kics scan on the following OpenApi file, results in a query evaluation error:
_The file_
```
openapi: "3.0.2"
info:
  title: POI Search
  version: "1.0.1"
servers:
  - url: https://api.server.test/v1
paths:
  /test:
    summary: test test
components:
  schemas:
    PointGenre:
      type: string
      minimum: 13
      maximum: 13
```

> Error & debugs:
> 12:13PM ERR Inspector. query executed with error, query=type_has_invalid_keyword error="failed to evaluate query: type_has_invalid_keyword:31: eval_conflict_error: functions must not produce multiple outputs for same inputs"
> 12:13PM DBG Error Report:
> {
>   "location": "func Inspect()",
>   "flags": {
>     "analyze-path": [],
>     "analyze-results": "platforms.json",
>     "bom": false,
>     "ci": true,
>     "cloud-provider": [
>       ""
>     ],
>     "config": "",
>     "disable-full-descriptions": false,
>     "disable-secrets": false,
>     "exclude-categories": [],
>     "exclude-gitignore": false,
>     "exclude-paths": [],
>     "exclude-queries": [],
>     "exclude-results": [],
>     "exclude-severities": [],
>     "exclude-type": [
>       ""
>     ],
>     "experimental-queries": [],
>     "fail-on": [
>       "high",
>       "medium",
>       "low",
>       "info"
>     ],
>     "ignore-on-exit": "none",
>     "include-ids": [
>       "all"
>     ],
>     "include-queries": [],
>     "input-data": "",
>     "libraries-path": "./assets/libraries",
>     "log-file": false,
>     "log-format": "pretty",
>     "log-level": "TRACE",
>     "log-path": "",
>     "minimal-ui": false,
>     "no-color": false,
>     "no-progress": false,
>     "output-name": "results",
>     "output-path": "",
>     "path": [
>       "/path/bla.yml"
>     ],
>     "payload-lines": false,
>     "payload-path": "",
>     "preview-lines": 3,
>     "profiling": "",
>     "queries-path": [
>       "./assets/queries"
>     ],
>     "report-formats": [
>       "json"
>     ],
>     "results": "",
>     "secrets-regexes-path": "",
>     "silent": false,
>     "terraform-vars-path": "",
>     "timeout": 60,
>     "type": [
>       ""
>     ],
>     "verbose": false
>   },
>   "file_name": "",
>   "query_name": "type_has_invalid_keyword",
>   "platform": "openAPI",
>   "kind": "",
>   "query_metadata": {
>     "aggregation": 4,
>     "category": "Structure and Semantics",
>     "descriptionID": "d7b8c860",
>     "descriptionText": "Schema Object define type should not use a keyword of another type",
>     "descriptionUrl": "https://swagger.io/specification/#schema-object",
>     "id": "a9228976-10cf-4b5f-b902-9e962aad037a",
>     "override": {
>       "2.0": {
>         "descriptionText": "Schema/Parameter/Header Object define type should not use a keyword of another type",
>         "descriptionUrl": "https://swagger.io/specification/v2/#schemaObject",
>         "id": "492c6cbb-f3f8-4807-aa4f-42b8b1c46b59",
>         "queryName": "Type Has Invalid Keyword (v2)"
>       }
>     },
>     "platform": "OpenAPI",
>     "queryName": "Type Has Invalid Keyword (v3)",
>     "severity": "INFO"
>   },
>   "message": "Inspector. query executed with error, query=type_has_invalid_keyword",
>   "error": {},
>   "additional_values": null
> }


Discussion / hints:
Please, follow the guideline for an issue title: 

For **bug**:

`bug(<scope>): <title starting with lowercase letter>`

For **query**:

`query(<platform>): <title starting with lowercase letter>`

For **feature request**:

`feat(<scope>): <title starting with lowercase letter>`

Thank you!
*KICS Team*
<!-- thollander/actions-comment-pull-request "title_check" -->

Fix patch:
diff --git a/assets/queries/openAPI/general/type_has_invalid_keyword/query.rego b/assets/queries/openAPI/general/type_has_invalid_keyword/query.rego
index 863592fa1fe..75d4a933f66 100644
--- a/assets/queries/openAPI/general/type_has_invalid_keyword/query.rego
+++ b/assets/queries/openAPI/general/type_has_invalid_keyword/query.rego
@@ -17,24 +17,26 @@ CxPolicy[result] {
 
 	[path, value] := walk(doc)
 	common_lib.valid_key(value, "type")
-	invalidKey := check_keywords(value)
+	invalidKeys := check_keywords(value)
 	result := {
 		"documentId": doc.id,
-		"searchKey": sprintf("%s.%s", [openapi_lib.concat_path(path), invalidKey]),
+		"searchKey": sprintf("%s.%s", [openapi_lib.concat_path(path), invalidKeys[a]]),
 		"issueType": "IncorrectValue",
 		"keyExpectedValue": "There shouldn't be any invalid keywords",
-		"keyActualValue": sprintf("Keyword %s is not valid for type %s", [invalidKey, value.type]),
+		"keyActualValue": sprintf("Keyword %s is not valid for type %s", [invalidKeys[a], value.type]),
 		"overrideKey": version,
 	}
 }
 
-check_keywords(value) = name {
-	keywords := specificKeywords[type]
-	typeName := get_value_type(value.type)
-	type != typeName
-	value[key]
-	common_lib.inArray(keywords, key)
-	name := key
+check_keywords(value) = invalidKeys {
+	invalidKeys := { invalidKeyword |
+        keywords := specificKeywords[type]
+		typeName := get_value_type(value.type)
+		type != typeName
+		value[key]
+		common_lib.inArray(keywords, key)
+		invalidKeyword := key
+    }
 }
 
 get_value_type(type) = typeName {
@@ -43,3 +45,4 @@ get_value_type(type) = typeName {
 } else = typeName {
 	typeName := type
 }
+


Test patch:
diff --git a/assets/queries/openAPI/general/type_has_invalid_keyword/test/positive11.yaml b/assets/queries/openAPI/general/type_has_invalid_keyword/test/positive11.yaml
new file mode 100644
index 00000000000..7c3eb155ef5
--- /dev/null
+++ b/assets/queries/openAPI/general/type_has_invalid_keyword/test/positive11.yaml
@@ -0,0 +1,15 @@
+openapi: "3.0.2"
+info:
+  title: POI Search
+  version: "1.0.1"
+servers:
+  - url: https://api.server.test/v1
+paths:
+  /test:
+    summary: test test
+components:
+  schemas:
+    PointGenre:
+      type: string
+      minimum: 13
+      maximum: 13
diff --git a/assets/queries/openAPI/general/type_has_invalid_keyword/test/positive_expected_result.json b/assets/queries/openAPI/general/type_has_invalid_keyword/test/positive_expected_result.json
index 832fde20bed..8050e654697 100644
--- a/assets/queries/openAPI/general/type_has_invalid_keyword/test/positive_expected_result.json
+++ b/assets/queries/openAPI/general/type_has_invalid_keyword/test/positive_expected_result.json
@@ -106,5 +106,17 @@
     "severity": "INFO",
     "line": 17,
     "filename": "positive10.yaml"
+  },
+  {
+    "queryName": "Type Has Invalid Keyword (v3)",
+    "severity": "INFO",
+    "line": 14,
+    "filename": "positive11.yaml"
+  },
+  {
+    "queryName": "Type Has Invalid Keyword (v3)",
+    "severity": "INFO",
+    "line": 15,
+    "filename": "positive11.yaml"
   }
 ]