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

Enabling GDPR compliance checks #64

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e1d81e2
feat: added support for recognition of database query types
interruptedHandshake Feb 25, 2023
19ba7f0
Merge branch 'main' of https://github.com/interruptedHandshake/cloud-…
interruptedHandshake Feb 25, 2023
4e5b295
feat: created testcases for compliance checks
interruptedHandshake Mar 2, 2023
43c1db5
feat: added support for detection of DELETE and PUT HttpRequest of py…
interruptedHandshake Mar 2, 2023
2b922e7
feat: created initial queries for compliance checks
interruptedHandshake Mar 2, 2023
155c46c
add: enhanced example for data portability with transfer to external …
interruptedHandshake Mar 3, 2023
641e44b
feat: compliance check query for art 20(2)
interruptedHandshake Mar 3, 2023
cc9f1d7
fix: adjusted config.yml for detection of correct application
interruptedHandshake Mar 11, 2023
0f1f5f7
feat: created article 19 checks and adjusted other checks
interruptedHandshake Mar 11, 2023
b9c236c
feat: created testcase for article 19 compliance check
interruptedHandshake Mar 11, 2023
227b94c
add: adjusted notification obligation testcase
interruptedHandshake Mar 16, 2023
9b1f6e4
feat: created validation testcase of art 19 (notification obligation)
interruptedHandshake Mar 16, 2023
5459469
delete: code clean up
interruptedHandshake Mar 16, 2023
3e40dd4
feat: created validation testcase for Art. 20 (right for data portabi…
interruptedHandshake Mar 16, 2023
1ce4f7e
feat: created testcase for Art. 16 validation
interruptedHandshake Mar 16, 2023
06fc565
feat: created validation testcase for At. 17
interruptedHandshake Mar 16, 2023
1cfe355
add: updated python validation for Art. 17
interruptedHandshake Mar 16, 2023
4f74c10
feat: created validation testcases and updated queries
interruptedHandshake Mar 16, 2023
85006b7
add: database query detection support for other libraries
interruptedHandshake Mar 20, 2023
415c777
add: updated testcase for validation of Art. 20
interruptedHandshake Mar 20, 2023
54e8aac
add: adjusted test suite
interruptedHandshake Mar 20, 2023
90feaea
add: adjusted code for testcase of Art.20
interruptedHandshake Mar 21, 2023
a515a31
add: reworked GDPR compliance checks
interruptedHandshake Mar 21, 2023
6030598
delete: removed obsolete code (code clean up)
interruptedHandshake Mar 21, 2023
fa61bfb
add: type property to ontology
interruptedHandshake Mar 24, 2023
d5eb701
feat: created performance test for evaluation of PPG extensions
interruptedHandshake Mar 24, 2023
65d6f2b
refactor: updated data type of type property according to ontology
interruptedHandshake Mar 24, 2023
ff07537
add: small testcase adjustements for Art 16 and Art 17
interruptedHandshake Mar 26, 2023
fa6accb
add: created testcase descriptions for test suite
interruptedHandshake Mar 26, 2023
8423f1e
refactor: reworked testcase art 16
interruptedHandshake Mar 26, 2023
5482d81
add: performance optimization of queries
interruptedHandshake Mar 26, 2023
2aec9c0
add: updated query of Art.19 for better detection of urls
interruptedHandshake Mar 26, 2023
5b41ec4
fix: adjusted configs and added missing mongo_host attribute
interruptedHandshake Mar 31, 2023
b28ec8d
add: adjusted testcases and added url prop to ontology
interruptedHandshake Apr 4, 2023
39ed8bf
feat: create FileWritePass + PythonFileWritePass + GoFileWritePass an…
interruptedHandshake Apr 8, 2023
28d33f3
refactor: updated queries according to updated ontology. registered P…
interruptedHandshake Apr 9, 2023
77bebb2
add: missing addition to translationResult
interruptedHandshake Apr 9, 2023
f8d516d
feat: created further testcases for enhancing the PPG in future work
interruptedHandshake Apr 10, 2023
e537e74
fix typo
interruptedHandshake Apr 10, 2023
969dbca
refactor: changed code to be tested to Article 20 testcase code
interruptedHandshake Apr 15, 2023
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
1 change: 1 addition & 0 deletions cloudpg/src/main/java/io/clouditor/graph/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ object App : Callable<Int> {
.registerPass(GormDatabasePass())
.registerPass(PyMongoPass())
.registerPass(Psycopg2Pass())
.registerPass(PythonFileWritePass())
.processAnnotations(true)

if (labelsEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import de.fraunhofer.aisec.cpg.graph.Node

open class PseudoIdentifier(labeledNode: Node) : DataLabel(labeledNode) {
override fun areMergeable(l: Label): Boolean {
return l::class == PseudoIdentifier::class
return false
//return l::class == PseudoIdentifier::class
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ abstract class DatabaseOperationPass : Pass() {
connect: DatabaseConnect,
storage: List<DatabaseStorage>,
calls: List<CallExpression>,
app: Application?
app: Application?,
type: String
): DatabaseQuery {
val op = DatabaseQuery(modify, calls, storage, connect.to)
val op = DatabaseQuery(modify, type, calls, storage, connect.to)
op.location = app?.location

storage.forEach {
Expand Down
25 changes: 25 additions & 0 deletions cloudpg/src/main/java/io/clouditor/graph/passes/FileWritePass.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.clouditor.graph.passes

import de.fraunhofer.aisec.cpg.TranslationResult
import de.fraunhofer.aisec.cpg.graph.statements.expressions.CallExpression
import de.fraunhofer.aisec.cpg.passes.Pass
import io.clouditor.graph.Application
import io.clouditor.graph.FileWrite
import io.clouditor.graph.plusAssign

abstract class FileWritePass: Pass() {

protected fun createFileWrite(
t: TranslationResult,
call: CallExpression,
app: Application?
): FileWrite {
// Create node
val fileWriteNode = FileWrite(call)
// Add to functionalities if necessary
app?.functionalities?.plusAssign(fileWriteNode)
// Add to translation result
t += fileWriteNode
return fileWriteNode
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import de.fraunhofer.aisec.cpg.processing.IVisitor
import de.fraunhofer.aisec.cpg.processing.strategy.Strategy
import io.clouditor.graph.*
import io.clouditor.graph.nodes.getStorageOrCreate
import io.clouditor.graph.utils.DatabaseQueryType

class GormDatabasePass : DatabaseOperationPass() {
override fun accept(t: TranslationResult) {
Expand Down Expand Up @@ -116,7 +117,16 @@ class GormDatabasePass : DatabaseOperationPass() {

val op =
app?.functionalities?.filterIsInstance<DatabaseConnect>()?.firstOrNull()?.let {
val op = createDatabaseQuery(result, false, it, mutableListOf(), calls, app)
val op =
createDatabaseQuery(
result,
false,
it,
mutableListOf(),
calls,
app,
DatabaseQueryType.READ.toString()
)
op.name = call.name

// loop through the calls and set DFG edges
Expand Down Expand Up @@ -144,7 +154,8 @@ class GormDatabasePass : DatabaseOperationPass() {
it,
mutableListOf(),
mutableListOf(call),
app
app,
DatabaseQueryType.CREATE.toString()
)
op.name = call.name

Expand All @@ -165,7 +176,8 @@ class GormDatabasePass : DatabaseOperationPass() {
it,
mutableListOf(),
mutableListOf(call),
app
app,
DatabaseQueryType.UPDATE.toString()
)
op.name = call.name

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class HttpClientPass : Pass() {
app: Application?
): HttpRequest {
val endpoints = getEndpointsForUrl(t, url, method)
val request = HttpRequest(call, body, endpoints)
val request = HttpRequest(call, body, endpoints, url)
request.name = method
request.location = call.location

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.clouditor.graph.passes.python

import de.fraunhofer.aisec.cpg.ExperimentalPython
import de.fraunhofer.aisec.cpg.TranslationResult
import de.fraunhofer.aisec.cpg.graph.Node
import de.fraunhofer.aisec.cpg.graph.statements.expressions.MemberCallExpression
import de.fraunhofer.aisec.cpg.processing.IVisitor
import de.fraunhofer.aisec.cpg.processing.strategy.Strategy
import io.clouditor.graph.findApplicationByTU
import io.clouditor.graph.passes.FileWritePass

@ExperimentalPython
class GoFileWritePass: FileWritePass() {
override fun accept(t: TranslationResult) {
for (tu in t.translationUnits) {
tu.accept(
Strategy::AST_FORWARD,
object : IVisitor<Node?>() {
// check all MemberCallExpressions
fun visit(r: MemberCallExpression) {
// look for writeFile() call of os library
if (r.name == "WriteFile" && r.base.name == "os") {
createFileWrite(t, r, t.findApplicationByTU(tu))
}
}
}
)
}
}

override fun cleanup() {
// Nothing to do
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import de.fraunhofer.aisec.cpg.processing.strategy.Strategy
import io.clouditor.graph.*
import io.clouditor.graph.nodes.getStorageOrCreate
import io.clouditor.graph.passes.DatabaseOperationPass
import io.clouditor.graph.utils.DatabaseQueryType

class Psycopg2Pass : DatabaseOperationPass() {

Expand Down Expand Up @@ -148,7 +149,16 @@ class Psycopg2Pass : DatabaseOperationPass() {
val dbName = dbStorage.firstOrNull()?.name
val storage = connect.to.map { it.getStorageOrCreate(table ?: "", dbName) }

val op = createDatabaseQuery(result, false, connect, storage, mutableListOf(call), app)
val op =
createDatabaseQuery(
result,
false,
connect,
storage,
mutableListOf(call),
app,
DatabaseQueryType.UNKNOWN.toString()
)
op.name = call.name

// in the select case, the arguments are just arguments to the query itself and flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import de.fraunhofer.aisec.cpg.processing.strategy.Strategy
import io.clouditor.graph.*
import io.clouditor.graph.nodes.getStorageOrCreate
import io.clouditor.graph.passes.DatabaseOperationPass
import io.clouditor.graph.utils.DatabaseQueryType
import java.net.URI

class PyMongoPass : DatabaseOperationPass() {
Expand Down Expand Up @@ -168,14 +169,68 @@ class PyMongoPass : DatabaseOperationPass() {
var (connect, storage) = pair
var op: DatabaseQuery? = null
if (mce.name == "insert_one") {
op = createDatabaseQuery(t, true, connect, storage, listOf(mce), app)
op =
createDatabaseQuery(
t,
true,
connect,
storage,
listOf(mce),
app,
DatabaseQueryType.CREATE.toString()
)

// data flows from first argument to op
mce.arguments.firstOrNull()?.addNextDFG(op)
}

if (mce.name == "find" || mce.name == "find_one") {
op = createDatabaseQuery(t, false, connect, storage, listOf(mce), app)
op =
createDatabaseQuery(
t,
false,
connect,
storage,
listOf(mce),
app,
DatabaseQueryType.READ.toString()
)
// data flows from first argument to op
mce.arguments.firstOrNull()?.addNextDFG(op)

// and towards the DFG target(s) of the call
mce.nextDFG.forEach { op!!.addNextDFG(it) }
}

if (mce.name == "delete_one" || mce.name == "delete_many") {
op =
createDatabaseQuery(
t,
true,
connect,
storage,
listOf(mce),
app,
DatabaseQueryType.DELETE.toString()
)
// data flows from first argument to op
mce.arguments.firstOrNull()?.addNextDFG(op)

// and towards the DFG target(s) of the call
mce.nextDFG.forEach { op!!.addNextDFG(it) }
}

if (mce.name == "update_one" || mce.name == "update_many") {
op =
createDatabaseQuery(
t,
true,
connect,
storage,
listOf(mce),
app,
DatabaseQueryType.UPDATE.toString()
)
// data flows from first argument to op
mce.arguments.firstOrNull()?.addNextDFG(op)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.clouditor.graph.passes.python

import de.fraunhofer.aisec.cpg.ExperimentalPython
import de.fraunhofer.aisec.cpg.TranslationResult
import de.fraunhofer.aisec.cpg.graph.Node
import de.fraunhofer.aisec.cpg.graph.statements.expressions.MemberCallExpression
import de.fraunhofer.aisec.cpg.processing.IVisitor
import de.fraunhofer.aisec.cpg.processing.strategy.Strategy
import io.clouditor.graph.findApplicationByTU
import io.clouditor.graph.passes.FileWritePass

@ExperimentalPython
class PythonFileWritePass: FileWritePass() {
override fun accept(t: TranslationResult) {
for (tu in t.translationUnits) {
tu.accept(
Strategy::AST_FORWARD,
object : IVisitor<Node?>() {
fun visit(r: MemberCallExpression) {
// look for write() call
if (r.name == "write") {
createFileWrite(t, r, t.findApplicationByTU(tu))
}
}
}
)
}
}

override fun cleanup() {
// Nothing to do
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class RequestsPass : HttpClientPass() {
handleClientRequest(tu, t, r, "GET")
} else if (r.name == "post" && r.base.name == "requests") {
handleClientRequest(tu, t, r, "POST")
} else if (r.name == "delete" && r.base.name == "requests") {
handleClientRequest(tu, t, r, "DELETE")
} else if (r.name == "put" && r.base.name == "requests") {
handleClientRequest(tu, t, r, "PUT")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.clouditor.graph.utils

enum class DatabaseQueryType {
CREATE,
READ,
UPDATE,
DELETE,
UNKNOWN
}
Loading