Rust: adjust integration tests and expected output

This commit is contained in:
Arthur Baars
2025-04-30 17:10:33 +02:00
parent 53b2e9708c
commit 8e8efedb42
14 changed files with 88 additions and 9 deletions

View File

@@ -30,7 +30,7 @@
"pretty": "__REDACTED__"
}
},
"numberOfFiles": 5,
"numberOfFiles": 6,
"numberOfManifests": 1
},
"severity": "note",

View File

@@ -1,4 +1,6 @@
| Cargo.toml:0:0:0:0 | LoadManifest(Cargo.toml) |
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
| file://:0:0:0:0 | CrateGraph |
| file://:0:0:0:0 | FindManifests |
| src/directory_module/mod.rs:0:0:0:0 | Extract(src/directory_module/mod.rs) |

View File

@@ -1,4 +1,27 @@
import codeql.rust.elements.internal.ExtractorStep
from ExtractorStep step
private class Step instanceof ExtractorStep {
string toString() {
result = super.getAction() + "(" + this.getFilePath() + ")"
or
not super.hasFile() and result = super.getAction()
}
private string getFilePath() {
exists(File file | file = super.getFile() |
exists(file.getRelativePath()) and result = file.getAbsolutePath()
or
not exists(file.getRelativePath()) and result = "/" + file.getBaseName()
)
}
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
super.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
filepath = this.getFilePath()
}
}
from Step step
select step

View File

@@ -1,3 +1,5 @@
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
| file://:0:0:0:0 | CrateGraph |
| file://:0:0:0:0 | FindManifests |
| rust-project.json:0:0:0:0 | LoadManifest(rust-project.json) |

View File

@@ -9,7 +9,7 @@
| Inconsistencies - Path resolution | 0 |
| Inconsistencies - SSA | 0 |
| Inconsistencies - data flow | 0 |
| Lines of code extracted | 6 |
| Lines of code extracted | 23 |
| Lines of user code extracted | 6 |
| Macro calls - resolved | 2 |
| Macro calls - total | 2 |

View File

@@ -30,7 +30,7 @@
"pretty": "__REDACTED__"
}
},
"numberOfFiles": 4,
"numberOfFiles": 5,
"numberOfManifests": 1
},
"severity": "note",

View File

@@ -30,7 +30,7 @@
"pretty": "__REDACTED__"
}
},
"numberOfFiles": 4,
"numberOfFiles": 5,
"numberOfManifests": 1
},
"severity": "note",

View File

@@ -5,6 +5,8 @@
| exe/src/main.rs:0:0:0:0 | Extract(exe/src/main.rs) |
| exe/src/main.rs:0:0:0:0 | LoadSource(exe/src/main.rs) |
| exe/src/main.rs:0:0:0:0 | Parse(exe/src/main.rs) |
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
| file://:0:0:0:0 | CrateGraph |
| file://:0:0:0:0 | FindManifests |
| lib/src/a_module/mod.rs:0:0:0:0 | Extract(lib/src/a_module/mod.rs) |

View File

@@ -1,4 +1,27 @@
import codeql.rust.elements.internal.ExtractorStep
from ExtractorStep step
private class Step instanceof ExtractorStep {
string toString() {
result = super.getAction() + "(" + this.getFilePath() + ")"
or
not super.hasFile() and result = super.getAction()
}
private string getFilePath() {
exists(File file | file = super.getFile() |
exists(file.getRelativePath()) and result = file.getAbsolutePath()
or
not exists(file.getRelativePath()) and result = "/" + file.getBaseName()
)
}
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
super.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
filepath = this.getFilePath()
}
}
from Step step
select step

View File

@@ -4,6 +4,8 @@
| exe/src/main.rs:0:0:0:0 | Extract(exe/src/main.rs) |
| exe/src/main.rs:0:0:0:0 | LoadSource(exe/src/main.rs) |
| exe/src/main.rs:0:0:0:0 | Parse(exe/src/main.rs) |
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
| file://:0:0:0:0 | CrateGraph |
| file://:0:0:0:0 | FindManifests |
| lib/src/a_module/mod.rs:0:0:0:0 | Extract(lib/src/a_module/mod.rs) |

View File

@@ -9,7 +9,7 @@
| Inconsistencies - Path resolution | 0 |
| Inconsistencies - SSA | 0 |
| Inconsistencies - data flow | 0 |
| Lines of code extracted | 9 |
| Lines of code extracted | 26 |
| Lines of user code extracted | 9 |
| Macro calls - resolved | 2 |
| Macro calls - total | 2 |

View File

@@ -9,7 +9,7 @@
| Inconsistencies - Path resolution | 0 |
| Inconsistencies - SSA | 0 |
| Inconsistencies - data flow | 0 |
| Lines of code extracted | 9 |
| Lines of code extracted | 26 |
| Lines of user code extracted | 9 |
| Macro calls - resolved | 2 |
| Macro calls - total | 2 |

View File

@@ -1,6 +1,8 @@
| Cargo.toml:0:0:0:0 | LoadManifest(Cargo.toml) |
| exe/src/main.rs:0:0:0:0 | Extract(exe/src/main.rs) |
| exe/src/main.rs:0:0:0:0 | Parse(exe/src/main.rs) |
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
| file://:0:0:0:0 | CrateGraph |
| file://:0:0:0:0 | FindManifests |
| lib/src/lib.rs:0:0:0:0 | Extract(lib/src/lib.rs) |

View File

@@ -1,4 +1,27 @@
import codeql.rust.elements.internal.ExtractorStep
from ExtractorStep step
private class Step instanceof ExtractorStep {
string toString() {
result = super.getAction() + "(" + this.getFilePath() + ")"
or
not super.hasFile() and result = super.getAction()
}
private string getFilePath() {
exists(File file | file = super.getFile() |
exists(file.getRelativePath()) and result = file.getAbsolutePath()
or
not exists(file.getRelativePath()) and result = "/" + file.getBaseName()
)
}
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
super.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
filepath = this.getFilePath()
}
}
from Step step
select step