mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
QL: Clean up structured logs module
Pushes it into an internal module and removes the abstract class.
This commit is contained in:
@@ -3,9 +3,8 @@ private import codeql_ql.ast.internal.TreeSitter
|
|||||||
|
|
||||||
class Object extends JSON::Object {
|
class Object extends JSON::Object {
|
||||||
JSON::Value getValue(string key) {
|
JSON::Value getValue(string key) {
|
||||||
exists(JSON::Pair p |
|
exists(JSON::Pair p | p = this.getChild(_) |
|
||||||
p = this.getChild(_) and p.getKey().(JSON::String).getChild().getValue() = key
|
key = p.getKey().(JSON::String).getChild().getValue() and
|
||||||
|
|
|
||||||
result = p.getValue()
|
result = p.getValue()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -35,104 +34,106 @@ class Array extends JSON::Array {
|
|||||||
Array getArray(int i) { result = this.getChild(i) }
|
Array getArray(int i) { result = this.getChild(i) }
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class LogEntry extends Object { }
|
module EvaluatorLog {
|
||||||
|
class Entry extends Object { }
|
||||||
|
|
||||||
class LogHeader extends LogEntry {
|
class LogHeader extends Entry {
|
||||||
LogHeader() { this.getType() = "LOG_HEADER" }
|
LogHeader() { this.getType() = "LOG_HEADER" }
|
||||||
|
|
||||||
string getCodeQLVersion() { result = this.getString("codeqlVersion") }
|
string getCodeQLVersion() { result = this.getString("codeqlVersion") }
|
||||||
|
|
||||||
string getLogVersion() { result = this.getString("logVersion") }
|
string getLogVersion() { result = this.getString("logVersion") }
|
||||||
}
|
|
||||||
|
|
||||||
class QueryStarted extends LogEntry {
|
|
||||||
QueryStarted() { this.getType() = "QUERY_STARTED" }
|
|
||||||
|
|
||||||
string getQueryName() { result = this.getString("queryName") }
|
|
||||||
|
|
||||||
int getStage(int i) { result = this.getArray("stage").getNumber(i) }
|
|
||||||
}
|
|
||||||
|
|
||||||
class PredicateStarted extends LogEntry {
|
|
||||||
PredicateStarted() { this.getType() = "PREDICATE_STARTED" }
|
|
||||||
|
|
||||||
string getPredicateName() { result = this.getString("predicateName") }
|
|
||||||
|
|
||||||
string getPosition() { result = this.getString("position") }
|
|
||||||
|
|
||||||
string getPredicateType() { result = this.getString("predicateType") }
|
|
||||||
|
|
||||||
int getQueryCausingWork() { result = this.getNumber("queryCausingWork") }
|
|
||||||
|
|
||||||
string getRAHash() { result = this.getString("raHash") }
|
|
||||||
|
|
||||||
Object getRA() { result = this.getValue("ra") }
|
|
||||||
|
|
||||||
string getDependency(string key) { result = this.getObject("dependencies").getString(key) }
|
|
||||||
}
|
|
||||||
|
|
||||||
class PipelineStarted extends LogEntry {
|
|
||||||
PipelineStarted() { this.getType() = "PIPELINE_STARTED" }
|
|
||||||
|
|
||||||
int getPredicateStartEvent() { result = this.getNumber("predicateStartEvent") }
|
|
||||||
|
|
||||||
string getRAReference() { result = this.getString("raReference") }
|
|
||||||
}
|
|
||||||
|
|
||||||
class PipelineCompleted extends LogEntry {
|
|
||||||
PipelineCompleted() { this.getType() = "PIPELINE_COMPLETED" }
|
|
||||||
|
|
||||||
int getStartEvent() { result = this.getNumber("startEvent") }
|
|
||||||
|
|
||||||
string getRAReference() { result = this.getString("raReference") }
|
|
||||||
|
|
||||||
int getCount(int i) { result = this.getArray("counts").getNumber(i) }
|
|
||||||
|
|
||||||
int getDuplicationPercentage(int i) {
|
|
||||||
result = this.getArray("duplicationPercentages").getNumber(i)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int getResultSize() { result = this.getNumber("resultSize") }
|
class QueryStarted extends Entry {
|
||||||
}
|
QueryStarted() { this.getType() = "QUERY_STARTED" }
|
||||||
|
|
||||||
class PredicateCompleted extends LogEntry {
|
string getQueryName() { result = this.getString("queryName") }
|
||||||
PredicateCompleted() { this.getType() = "PREDICATE_COMPLETED" }
|
|
||||||
|
|
||||||
int getStartEvent() { result = this.getNumber("startEvent") }
|
int getStage(int i) { result = this.getArray("stage").getNumber(i) }
|
||||||
|
}
|
||||||
|
|
||||||
int getResultSize() { result = this.getNumber("resultSize") }
|
class PredicateStarted extends Entry {
|
||||||
}
|
PredicateStarted() { this.getType() = "PREDICATE_STARTED" }
|
||||||
|
|
||||||
class QueryCompleted extends LogEntry {
|
string getPredicateName() { result = this.getString("predicateName") }
|
||||||
QueryCompleted() { this.getType() = "QUERY_COMPLETED" }
|
|
||||||
|
|
||||||
int getStartEvent() { result = this.getNumber("startEvent") }
|
string getPosition() { result = this.getString("position") }
|
||||||
|
|
||||||
string getTerminationType() { result = this.getString("terminationType") }
|
string getPredicateType() { result = this.getString("predicateType") }
|
||||||
}
|
|
||||||
|
|
||||||
class LogFooter extends LogEntry {
|
int getQueryCausingWork() { result = this.getNumber("queryCausingWork") }
|
||||||
LogFooter() { this.getType() = "LOG_FOOTER" }
|
|
||||||
}
|
|
||||||
|
|
||||||
class CacheLookup extends LogEntry {
|
string getRAHash() { result = this.getString("raHash") }
|
||||||
CacheLookup() { this.getType() = "CACHE_LOOKUP" }
|
|
||||||
|
|
||||||
int getRelationSize() { result = this.getNumber("relationSize") }
|
Object getRA() { result = this.getValue("ra") }
|
||||||
}
|
|
||||||
|
|
||||||
class SentinelEmpty extends LogEntry {
|
string getDependency(string key) { result = this.getObject("dependencies").getString(key) }
|
||||||
SentinelEmpty() { this.getType() = "SENTINEL_EMPTY" }
|
}
|
||||||
|
|
||||||
|
class PipelineStarted extends Entry {
|
||||||
|
PipelineStarted() { this.getType() = "PIPELINE_STARTED" }
|
||||||
|
|
||||||
|
int getPredicateStartEvent() { result = this.getNumber("predicateStartEvent") }
|
||||||
|
|
||||||
|
string getRAReference() { result = this.getString("raReference") }
|
||||||
|
}
|
||||||
|
|
||||||
|
class PipelineCompleted extends Entry {
|
||||||
|
PipelineCompleted() { this.getType() = "PIPELINE_COMPLETED" }
|
||||||
|
|
||||||
|
int getStartEvent() { result = this.getNumber("startEvent") }
|
||||||
|
|
||||||
|
string getRAReference() { result = this.getString("raReference") }
|
||||||
|
|
||||||
|
int getCount(int i) { result = this.getArray("counts").getNumber(i) }
|
||||||
|
|
||||||
|
int getDuplicationPercentage(int i) {
|
||||||
|
result = this.getArray("duplicationPercentages").getNumber(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
int getResultSize() { result = this.getNumber("resultSize") }
|
||||||
|
}
|
||||||
|
|
||||||
|
class PredicateCompleted extends Entry {
|
||||||
|
PredicateCompleted() { this.getType() = "PREDICATE_COMPLETED" }
|
||||||
|
|
||||||
|
int getStartEvent() { result = this.getNumber("startEvent") }
|
||||||
|
|
||||||
|
int getResultSize() { result = this.getNumber("resultSize") }
|
||||||
|
}
|
||||||
|
|
||||||
|
class QueryCompleted extends Entry {
|
||||||
|
QueryCompleted() { this.getType() = "QUERY_COMPLETED" }
|
||||||
|
|
||||||
|
int getStartEvent() { result = this.getNumber("startEvent") }
|
||||||
|
|
||||||
|
string getTerminationType() { result = this.getString("terminationType") }
|
||||||
|
}
|
||||||
|
|
||||||
|
class LogFooter extends Entry {
|
||||||
|
LogFooter() { this.getType() = "LOG_FOOTER" }
|
||||||
|
}
|
||||||
|
|
||||||
|
class CacheLookup extends Entry {
|
||||||
|
CacheLookup() { this.getType() = "CACHE_LOOKUP" }
|
||||||
|
|
||||||
|
int getRelationSize() { result = this.getNumber("relationSize") }
|
||||||
|
}
|
||||||
|
|
||||||
|
class SentinelEmpty extends Entry {
|
||||||
|
SentinelEmpty() { this.getType() = "SENTINEL_EMPTY" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stuff to test whether we've covered all event types
|
// Stuff to test whether we've covered all event types
|
||||||
private File logFile() { result = any(LogHeader h).getLocation().getFile() }
|
private File logFile() { result = any(EvaluatorLog::LogHeader h).getLocation().getFile() }
|
||||||
|
|
||||||
private Object missing() {
|
private Object missing() {
|
||||||
result =
|
result =
|
||||||
any(Object o |
|
any(Object o |
|
||||||
o.getLocation().getFile() = logFile() and
|
o.getLocation().getFile() = logFile() and
|
||||||
not o instanceof LogEntry and
|
not o instanceof EvaluatorLog::Entry and
|
||||||
not exists(o.getParent().getParent()) // don't count nested objects
|
not exists(o.getParent().getParent()) // don't count nested objects
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user