@@ -29,35 +29,41 @@ if [ "$RES" -ne "$EXPECTING" ]; then
2929 exit 1
3030fi
3131
32- status1=` jq ' .runs[0].results[0].properties.tags[1]' " ${REPO_DIR} /results1.json" `
32+ read -r -d ' ' JQ_QUERY << 'EOF '
33+ [.runs[].results[] | select(.locations[0].physicalLocation.artifactLocation.uri == $uri)][ $idx ]
34+ | .properties.tags[]?
35+ | select(startswith("DATADOG_SECRET_VALIDATION_STATUS:"))
36+ EOF
37+
38+ status1=$( jq --arg uri " datadog-keys.sh" --argjson idx 0 " $JQ_QUERY " " ${REPO_DIR} /results1.json" )
3339
3440if [ " $status1 " != " \" DATADOG_SECRET_VALIDATION_STATUS:INVALID\" " ]; then
3541 echo " status1: did not find DATADOG_SECRET_VALIDATION_STATUS:INVALID in properties, found $status1 "
3642 exit 1
3743fi
3844
39- status2=` jq ' .runs[0].results[1].properties.tags[1] ' " ${REPO_DIR} /results1.json" `
45+ status2=$( jq --arg uri " plop/foo_test.py " --argjson idx 0 " $JQ_QUERY " " $ {REPO_DIR} /results1.json" )
4046
4147if [ " $status2 " != " \" DATADOG_SECRET_VALIDATION_STATUS:NOT_VALIDATED\" " ]; then
4248 echo " status2: did not find DATADOG_SECRET_VALIDATION_STATUS:NOT_VALIDATED in properties, found $status2 "
4349 exit 1
4450fi
4551
46- status3=` jq ' .runs[0].results[2].properties.tags[1] ' " ${REPO_DIR} /results1.json" `
52+ status3=$( jq --arg uri " plop/foo_test.py " --argjson idx 1 " $JQ_QUERY " " $ {REPO_DIR} /results1.json" )
4753
4854if [ " $status3 " != " \" DATADOG_SECRET_VALIDATION_STATUS:NOT_VALIDATED\" " ]; then
4955 echo " status3: did not find DATADOG_SECRET_VALIDATION_STATUS:NOT_VALIDATED in properties, found $status3 "
5056 exit 1
5157fi
5258
5359# # Make sure the SDS ID is added to the SARIF file
54- status4=` jq ' .runs[0].tool.driver.rules[0].properties.tags[1] ' " ${REPO_DIR} /results1.json" `
60+ status4=` jq ' .runs[0].tool.driver.rules[0].properties.tags[] | select(startswith("DATADOG_SDS_ID:")) ' " ${REPO_DIR} /results1.json" `
5561
56- if [ " $status4 " != " \" DATADOG_SDS_ID:5ef83eb0-4137-48a2-a28b-2402c185863c \" " ]; then
57- echo " status3: did not find DATADOG_SDS_ID:5ef83eb0-4137-48a2-a28b-2402c185863c in properties, found $status4 "
62+ if [ -z " $status4 " ]; then
63+ echo " did not find DATADOG_SDS_ID in tags "
5864 exit 1
5965fi
6066
6167echo " All tests passed"
6268
63- exit 0
69+ exit 0
0 commit comments