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

Fix style of docs #1504

Merged
merged 5 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ class Schema {
}

if (inheritedRels[entityLabel]?.isNotEmpty() == true) {
out.println("<details markdown><summary>Inherited Relationships</summary>")
out.println("<div class=\"papers\" markdown>")
out.println("??? info \"Inherited Relationships\"")
out.println()
removeLabelDuplicates(inheritedRels[entityLabel])?.forEach { inherited ->
var current = classInfo
Expand All @@ -379,14 +380,15 @@ class Schema {
}
hierarchy[current]?.first?.let { current = it }
}
out.print(" ")
out.println(
getBoxWithClass(
"inherited-relationship",
"[${inherited.second}](#${toConcatName(toLabel(baseClass) + inherited.second)})"
)
)
}
out.println("</details>")
out.println("</div>")
out.println()
}

Expand All @@ -403,12 +405,13 @@ class Schema {
out.println()
}
if (inheritedProperties[entityLabel]?.isNotEmpty() == true) {
out.println("<details markdown><summary>Inherited Properties</summary>")
out.println("<div class=\"papers\" markdown>")
out.println("??? info \"Inherited Properties\"")
removeLabelDuplicates(inheritedProperties[entityLabel])?.forEach {
out.println("${it.second} : ${it.first}")
out.println(" ${it.second} : ${it.first}")
out.println()
}
out.println("</details>")
out.println("</div>")
out.println()
}
}
Expand Down
146 changes: 73 additions & 73 deletions docs/docs/CPG/specs/dfg-function-summaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,84 +27,84 @@ An example of a file could look as follows:

=== "JSON"

```json
[
{
"functionDeclaration": {
"language": "de.fraunhofer.aisec.cpg.frontends.java.JavaLanguage",
"methodName": "java.util.List.addAll",
"signature": ["int", "java.util.Object"]
```json
[
{
"functionDeclaration": {
"language": "de.fraunhofer.aisec.cpg.frontends.java.JavaLanguage",
"methodName": "java.util.List.addAll",
"signature": ["int", "java.util.Object"]
},
"dataFlows": [
{
"from": "param1",
"to": "base",
"dfgType": "full"
}
]
},
"dataFlows": [
{
"from": "param1",
"to": "base",
"dfgType": "full"
}
]
},
{
"functionDeclaration": {
"language": "de.fraunhofer.aisec.cpg.frontends.java.JavaLanguage",
"methodName": "java.util.List.addAll",
"signature": ["java.util.Object"]
{
"functionDeclaration": {
"language": "de.fraunhofer.aisec.cpg.frontends.java.JavaLanguage",
"methodName": "java.util.List.addAll",
"signature": ["java.util.Object"]
},
"dataFlows": [
{
"from": "param0",
"to": "base",
"dfgType": "full"
}
]
},
"dataFlows": [
{
"from": "param0",
"to": "base",
"dfgType": "full"
}
]
},
{
"functionDeclaration": {
"language": "de.fraunhofer.aisec.cpg.frontends.cxx.CLanguage",
"methodName": "memcpy"
},
"dataFlows": [
{
"from": "param1",
"to": "param0",
"dfgType": "full"
}
]
}
]
```
{
"functionDeclaration": {
"language": "de.fraunhofer.aisec.cpg.frontends.cxx.CLanguage",
"methodName": "memcpy"
},
"dataFlows": [
{
"from": "param1",
"to": "param0",
"dfgType": "full"
}
]
}
]
```

=== "YAML"

```yml
- functionDeclaration:
language: de.fraunhofer.aisec.cpg.frontends.java.JavaLanguage
methodName: java.util.List.addAll
signature:
- int
- java.util.Object
dataFlows:
- from: param1
to: base
dfgType: full

- functionDeclaration:
language: de.fraunhofer.aisec.cpg.frontends.java.JavaLanguage
methodName: java.util.List.addAll
signature:
- java.util.Object
dataFlows:
- from: param0
to: base
dfgType: full

- functionDeclaration:
language: de.fraunhofer.aisec.cpg.frontends.cxx.CLanguage
methodName: memcpy
dataFlows:
- from: param1
to: param0
dfgType: full
```
```yaml
- functionDeclaration:
language: de.fraunhofer.aisec.cpg.frontends.java.JavaLanguage
methodName: java.util.List.addAll
signature:
- int
- java.util.Object
dataFlows:
- from: param1
to: base
dfgType: full
- functionDeclaration:
language: de.fraunhofer.aisec.cpg.frontends.java.JavaLanguage
methodName: java.util.List.addAll
signature:
- java.util.Object
dataFlows:
- from: param0
to: base
dfgType: full
- functionDeclaration:
language: de.fraunhofer.aisec.cpg.frontends.cxx.CLanguage
methodName: memcpy
dataFlows:
- from: param1
to: param0
dfgType: full
```

This file configures the following edges:

Expand Down
61 changes: 24 additions & 37 deletions docs/docs/CPG/specs/dfg.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

The Data Flow Graph (DFG) is built as edges between nodes. Each node has a set of incoming data flows (`prevDFG`) and outgoing data flows (`nextDFG`). In the following, we summarize how different types of nodes construct the respective data flows.

{:style="background:#dddddd"}
[Statement](#estatement)

<span class="child">[Statement](#estatement)</span>

## CallExpression

Expand Down Expand Up @@ -73,38 +69,29 @@ For this reason, if the assignment's ast parent is not a `Block` (i.e., a block
If the `lhs` consists of multiple variables (or a tuple), we try to split up the `rhs` by the index. If we can't do this, the whole `rhs` flows to all variables in `lhs`.

Scheme:
```mermaid
flowchart LR
node([AssignExpression]) -.- rhs(rhs);
rhs -- DFG --> lhs;
node([AssignExpression]) -.- lhs(lhs);
```

```mermaid
flowchart LR
node([AssignExpression]) -.- lhs(lhs);
node([AssignExpression]) -.- rhs(rhs);
rhs -- DFG --> lhs;
rhs -- DFG --> node;
```

```mermaid
flowchart LR
A[assignment.rhs] -- DFG --> assignment.lhs;
subgraph S[If the ast parent is not a Block]
direction LR
assignment.rhs -- DFG --> assignment;
end
A --> S;
```

If size of `lhs` and `rhs` is equal:
```mermaid
flowchart LR
node([AssignExpression]) -.- rhs("rhs[i]");
rhs -- "for all i: DFG[i]" --> lhs;
node([AssignExpression]) -.- lhs("lhs[i]");
```
* Standard case:
```mermaid
flowchart LR
node([AssignExpression]) -.- rhs(rhs);
rhs -- DFG --> lhs;
node([AssignExpression]) -.- lhs(lhs);
```
* If the assignment happens inside another statement/expression (not inside a `Block`):
```mermaid
flowchart LR
node([AssignExpression]) -.- lhs(lhs);
node([AssignExpression]) -.- rhs(rhs);
rhs -- DFG --> lhs;
rhs -- DFG --> node;
```
* Since `lhs` and `rhs` can consist of multiple values, if size of `lhs` and `rhs` is equal, we actually make the DFG-edges for each indexed value:
```mermaid
flowchart LR
node([AssignExpression]) -.- rhs("rhs[i]");
rhs -- "for all i: DFG[i]" --> lhs;
node([AssignExpression]) -.- lhs("lhs[i]");
```

### Case 2: Compound assignment (`operatorCode: *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=` )

Expand Down Expand Up @@ -431,7 +418,7 @@ Interesting fields:

The value of the iterable flow to the `VariableDeclaration` in the `variable`. Since some languages allow arbitrary logic, we differentiate between two cases:

### Case 1. The `variable` is a `DeclarationStatement`.
#### Case 1. The `variable` is a `DeclarationStatement`.

This is the case for most languages where we can have only a variable in this place (e.g., `for(e in list)`). Here, we get the declaration(s) in the statement and add the DFG from the iterable to this declaration.

Expand All @@ -445,7 +432,7 @@ Scheme:
iterable -- for all i: DFG --> declarations
```

### Case 2. The `variable` is another type of `Statement`.
#### Case 2. The `variable` is another type of `Statement`.

In this case, we assume that the last VariableDeclaration is the one used for looping. We add a DFG edge only to this declaration.

Expand Down
Loading
Loading