1
1
private import ql
2
2
private import codeql_ql.ast.internal.TreeSitter
3
3
4
+ /** Gets a timestamp corresponding to the number of seconds since the date Semmle was founded. */
5
+ bindingset [ d, h, m, s, ms]
6
+ private float getTimestamp ( date d , int h , int m , int s , int ms ) {
7
+ result = ( ( "2006-12-28" .toDate ( ) .daysTo ( d ) * 24 + h ) * 60 + m ) * 60 + s + ms / 1000.0
8
+ }
9
+
10
+ bindingset [ str]
11
+ private float stringToTimestamp ( string str ) {
12
+ exists ( string r , date d , int h , int m , int s , int ms |
13
+ r = "(\\d{4}-\\d{2}-\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d{3})Z"
14
+ |
15
+ d = str .regexpCapture ( r , 1 ) .toDate ( ) and
16
+ h = str .regexpCapture ( r , 2 ) .toInt ( ) and
17
+ m = str .regexpCapture ( r , 3 ) .toInt ( ) and
18
+ s = str .regexpCapture ( r , 4 ) .toInt ( ) and
19
+ ms = str .regexpCapture ( r , 5 ) .toInt ( ) and
20
+ result = getTimestamp ( d , h , m , s , ms )
21
+ )
22
+ }
23
+
24
+ bindingset [ s]
25
+ private Predicate getPredicateFromPosition ( string s ) {
26
+ exists ( string r , string filepath , int startline | r = "(.*):(\\d+),(\\d+)-(\\d+),(\\d+)" |
27
+ filepath = s .regexpCapture ( r , 1 ) and
28
+ startline = s .regexpCapture ( r , 2 ) .toInt ( ) and
29
+ result .hasLocationInfo ( filepath , startline , _, _, _)
30
+ )
31
+ }
32
+
4
33
class Object extends JSON:: Object {
5
34
JSON:: Value getValue ( string key ) {
6
35
exists ( JSON:: Pair p | p = this .getChild ( _) |
@@ -24,6 +53,8 @@ class Object extends JSON::Object {
24
53
int getEventId ( ) { result = this .getNumber ( "event_id" ) }
25
54
26
55
string getTime ( ) { result = this .getString ( "time" ) }
56
+
57
+ float getTimestamp ( ) { result = stringToTimestamp ( this .getTime ( ) ) }
27
58
}
28
59
29
60
class Array extends JSON:: Array {
@@ -227,6 +258,8 @@ module KindPredicatesLog {
227
258
)
228
259
}
229
260
261
+ float getCompletionTime ( ) { result = stringToTimestamp ( this .getCompletionTimeString ( ) ) }
262
+
230
263
float getResultSize ( ) { result = this .getFloat ( "resultSize" ) }
231
264
}
232
265
@@ -278,6 +311,10 @@ module KindPredicatesLog {
278
311
Depencencies getDependencies ( ) { result = this .getObject ( "dependencies" ) }
279
312
280
313
PipeLineRun getPipelineRun ( ) { result .getArray ( ) = this .getArray ( "pipelineRuns" ) }
314
+
315
+ string getPosition ( ) { result = this .getString ( "position" ) }
316
+
317
+ Predicate getPredicate ( ) { result = getPredicateFromPosition ( this .getPosition ( ) ) }
281
318
}
282
319
283
320
class ComputeRecursive extends SummaryEvent {
0 commit comments