JS: Autoformat

This commit is contained in:
Asger Feldthaus
2021-03-01 10:28:50 +00:00
parent 12079cd1e4
commit 0bd60c1989
3 changed files with 18 additions and 17 deletions

View File

@@ -18,8 +18,7 @@ module JsonSchema {
}
/** A data flow node that is used a JSON schema. */
abstract class SchemaRoot extends DataFlow::Node {
}
abstract class SchemaRoot extends DataFlow::Node { }
/** An object literal with a `$schema` property indicating it is the root of a JSON schema. */
private class SchemaNodeByTag extends SchemaRoot, DataFlow::ObjectLiteralNode {
@@ -35,9 +34,7 @@ module JsonSchema {
or
result = getAPartOfJsonSchema(t.continue()).getAPropertySource()
or
exists(DataFlow::TypeBackTracker t2 |
result = getAPartOfJsonSchema(t2).backtrack(t2, t)
)
exists(DataFlow::TypeBackTracker t2 | result = getAPartOfJsonSchema(t2).backtrack(t2, t))
}
/** Gets a data flow node that is part of a JSON schema. */
@@ -68,7 +65,7 @@ module JsonSchema {
}
/**
* Gets an API node for a function produced by `new Ajv().compile()` or similar.
* Gets an API node for a function produced by `new Ajv().compile()` or similar.
*
* Note that this does not include the instance method `new Ajv().validate` as its
* signature is different.
@@ -83,9 +80,7 @@ module JsonSchema {
* Gets an API node that refers to an error produced by this Ajv instance.
*/
API::Node getAValidationError() {
exists(API::Node base |
base = [ref(), getAValidationFunction()]
|
exists(API::Node base | base = [ref(), getAValidationFunction()] |
result = base.getMember("errors")
or
result = base.getMember("errorsText").getReturn()
@@ -122,7 +117,12 @@ module JsonSchema {
private class AjvSchemaNode extends SchemaRoot {
AjvSchemaNode() {
this = any(Instance i).ref().getMember(["addSchema", "validate", "compile", "compileAsync"]).getParameter(0).getARhs()
this =
any(Instance i)
.ref()
.getMember(["addSchema", "validate", "compile", "compileAsync"])
.getParameter(0)
.getARhs()
}
}
}

View File

@@ -866,12 +866,15 @@ predicate isInterpretedAsRegExp(DataFlow::Node source) {
not exists(PropAccess p | p.getBase() = mce.getEnclosingExpr())
)
or
exists(DataFlow::SourceNode schema |
schema = JsonSchema::getAPartOfJsonSchema()
|
exists(DataFlow::SourceNode schema | schema = JsonSchema::getAPartOfJsonSchema() |
source = schema.getAPropertyWrite("pattern").getRhs()
or
source = schema.getAPropertySource("patternProperties").getAPropertyWrite().getPropertyNameExpr().flow()
source =
schema
.getAPropertySource("patternProperties")
.getAPropertyWrite()
.getPropertyNameExpr()
.flow()
)
)
}

View File

@@ -156,9 +156,7 @@ module ExceptionXss {
this = any(JsonSchema::Ajv::Instance i).getAValidationError().getAnImmediateUse()
}
override string getDescription() {
result = "JSON schema validation error"
}
override string getDescription() { result = "JSON schema validation error" }
}
/**