Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

fix taint_mode property parser #101

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/kotlin/com/bridgecrew/CheckovResult.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ data class CheckovResult(

data class Metadata(
val code_locations: List<DataFlow>?,
val taint_mode: List<DataFlow>?
val taint_mode: TaintMode?
)

data class TaintMode(
val data_flow: List<DataFlow>?
)

data class DataFlow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class WeaknessDictionaryPanel(private val result: WeaknessCheckovResult, private
}

private fun extractDataFlow(result: WeaknessCheckovResult): String? {
val dataFlow = result.metadata?.code_locations ?: result.metadata?.taint_mode
val dataFlow = result.metadata?.code_locations ?: result.metadata?.taint_mode?.data_flow
if (dataFlow !== null) {
return this.calculateDataFlow(dataFlow);
}
Expand All @@ -66,7 +66,7 @@ class WeaknessDictionaryPanel(private val result: WeaknessCheckovResult, private


private fun getDataFlowDictionary(result: WeaknessCheckovResult): Array<DataFlowDictionary>? {
val dataFlow = result.metadata?.code_locations ?: result.metadata?.taint_mode
val dataFlow = result.metadata?.code_locations ?: result.metadata?.taint_mode?.data_flow

if (dataFlow !== null) {
return dataFlow.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,31 @@ const val metadataCodeCollectionJson = """

const val metadataTaintModeJson = """
"metadata": {
"taint_mode": [{
"path": "/Users/sast-core/tests_policies/src/python/EncryptionKeySize.py",
"start": {
"row": 13,
"column": 0
},
"end": {
"row": 13,
"column": 66
},
"code_block": "cryptography.hazmat.primitives.asymmetric.rsa.generate_private_key"
}, {
"path": "/Users/sast-core/tests_policies/src/python/EncryptionKeySize.py",
"start": {
"row": 14,
"column": 73
},
"end": {
"row": 15,
"column": 86
},
"code_block": "key_size=size"
}]
"taint_mode":{
"data_flow": [{
"path": "/Users/sast-core/tests_policies/src/python/EncryptionKeySize.py",
"start": {
"row": 13,
"column": 0
},
"end": {
"row": 13,
"column": 66
},
"code_block": "cryptography.hazmat.primitives.asymmetric.rsa.generate_private_key"
}, {
"path": "/Users/sast-core/tests_policies/src/python/EncryptionKeySize.py",
"start": {
"row": 14,
"column": 73
},
"end": {
"row": 15,
"column": 86
},
"code_block": "key_size=size"
}]
}
},
"""

Expand Down
Loading