Commit c0f2cb8
authored
Add documentation members to Query (#1090)
Example usage in the `query-database`:
```
object CopyLoops extends QueryBundle {
@q
def isCopyLoop(): Query = Query(
name = "copy-loop",
author = Crew.fabs,
title = "Copy loop detected",
description =
"""
|For (buf, indices) pairs, determine those inside control structures (for, while, if ...)
|where any of the calls made outside of the body (block) are Inc operations. Determine
|the first argument of that Inc operation and check if they are used as indices for
|the write operation into the buffer.
|""".stripMargin,
score = 2,
startLine = sourcecode.Line(),
traversal = { cpg =>
cpg.assignment.target.isArrayAccess
.map { access =>
(access.array, access.subscripts.code.toSet)
}
.filter {
case (buf, subscripts) =>
val incIdentifiers = buf.inAst.isControlStructure.astChildren
.filterNot(_.isBlock)
.assignments
.target
.code
.toSet
(incIdentifiers & subscripts).nonEmpty
}
.map(_._1)
},
endLine = sourcecode.Line(),
fileName = sourcecode.FileName()
)
}
```1 parent ae192a5 commit c0f2cb8
2 files changed
Lines changed: 7 additions & 1 deletion
File tree
- console/src
- main/scala/io/shiftleft/console
- test/scala/io/shiftleft/console
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
0 commit comments