Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

Commit

Permalink
Add authors field and Crew object (#16)
Browse files Browse the repository at this point in the history
* Add authors field and `Crew` object

* Document generation of `querydb.json`
  • Loading branch information
fabsx00 authored Jan 1, 2021
1 parent 7a3690a commit b002c79
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,12 @@ If you want to test newly created queries with `joern-scan` as follows:
```
./install.sh && ./joern-scan <src>
```

## Exporting the database to JSON

You can launch
```
sbt run
```
to create a file named `querydb.json` that contains the list of all available queries
along with its meta information.
9 changes: 9 additions & 0 deletions src/main/scala/io/joern/scanners/Crew.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.joern.scanners

object Crew {

val suchakra = "@tuxology"
val niko = "@0x4D5A"
val fabs = "@fabsx00"

}
1 change: 1 addition & 0 deletions src/main/scala/io/joern/scanners/c/CopyLoops.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ object CopyLoops extends QueryBundle {
@q
def isCopyLoop(): Query = Query(
name = "copy-loop",
author = Crew.fabs,
title = "Copy loop detected",
description =
"""
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/io/joern/scanners/c/HeapBasedOverflow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ object HeapBasedOverflow extends QueryBundle {
@q
def mallocMemcpyIntOverflow()(implicit context: EngineContext): Query = Query(
name = "malloc-memcpy-int-overflow",
author = Crew.fabs,
title = "Dangerous copy-operation into heap-allocated buffer",
description = "-",
score = 4, { cpg =>
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/io/joern/scanners/c/InsecureFunctions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ object InsecureFunctions extends QueryBundle {
@q
def getsUsed(): Query = Query(
name = "call-to-gets",
author = Crew.suchakra,
title = "Insecure function gets() used",
description =
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ object IntegerTruncations extends QueryBundle {
@q
def strlenAssignmentTruncations(): Query = Query(
name = "strlen-truncation",
author = Crew.fabs,
title = "Truncation in assigment involving strlen call",
description = "-",
score = 2, { cpg =>
Expand Down
6 changes: 6 additions & 0 deletions src/main/scala/io/joern/scanners/c/Metrics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ object Metrics extends QueryBundle {
@q
def tooManyParameters(n: Int = 4): Query = Query(
name = "too-many-params",
author = Crew.fabs,
title = s"Number of parameters larger than $n",
description =
s"This query identifies functions with more than $n formal parameters",
Expand All @@ -19,6 +20,7 @@ object Metrics extends QueryBundle {
@q
def tooHighComplexity(n: Int = 4): Query = Query(
name = "too-high-complexity",
author = Crew.fabs,
title = s"Cyclomatic complexity higher than $n",
description =
s"This query identifies functions with a cyclomatic complexity higher than $n",
Expand All @@ -30,6 +32,7 @@ object Metrics extends QueryBundle {
@q
def tooLong(n: Int = 1000): Query = Query(
name = "too-long",
author = Crew.fabs,
title = s"More than $n lines",
description =
s"This query identifies functions that are more than $n lines long",
Expand All @@ -41,6 +44,7 @@ object Metrics extends QueryBundle {
@q
def multipleReturns(): Query = Query(
name = "multiple-returns",
author = Crew.fabs,
title = s"Multiple returns",
description = "This query identifies functions with more than one return",
score = 2.0, { cpg =>
Expand All @@ -51,6 +55,7 @@ object Metrics extends QueryBundle {
@q
def tooManyLoops(n: Int = 4): Query = Query(
name = "too-many-loops",
author = Crew.fabs,
title = s"More than $n loops",
description = s"This query identifies functions with more than $n loops",
score = 2, { cpg =>
Expand All @@ -63,6 +68,7 @@ object Metrics extends QueryBundle {
@q
def tooNested(n: Int = 3): Query = Query(
name = "too-nested",
author = Crew.fabs,
title = s"Nesting level higher than $n",
description =
s"This query identifies functions with a nesting level higher than $n",
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/io/joern/scanners/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package object scanners {
}

case class Query(name: String,
author: String,
title: String,
description: String,
score: Double,
Expand Down

0 comments on commit b002c79

Please sign in to comment.