Commit 06e0744 1 parent 25fa23e commit 06e0744 Copy full SHA for 06e0744
File tree 2 files changed +8
-6
lines changed
plugins/validate-response/checkers
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ import { compileExpression } from '../../utils/expression-parser'
34
34
import type { SymonConfig } from '../reporter'
35
35
import { newPagerDuty } from '../notification/channel/pagerduty'
36
36
37
- const HTTPMethods = [
37
+ const HTTPMethods = new Set ( [
38
38
'DELETE' ,
39
39
'GET' ,
40
40
'HEAD' ,
@@ -45,7 +45,7 @@ const HTTPMethods = [
45
45
'PURGE' ,
46
46
'LINK' ,
47
47
'UNLINK' ,
48
- ]
48
+ ] )
49
49
50
50
const setInvalidResponse = ( message : string ) : Validation => ( {
51
51
valid : false ,
@@ -284,7 +284,9 @@ const isValidProbeAlert = (alert: ProbeAlert | string): boolean => {
284
284
)
285
285
}
286
286
287
- return Boolean ( compileExpression ( alert . assertion ) )
287
+ return Boolean (
288
+ compileExpression ( alert . assertion || ( alert . query as string ) )
289
+ )
288
290
} catch {
289
291
return false
290
292
}
@@ -357,7 +359,7 @@ export const validateConfig = (configuration: Config): Validation => {
357
359
return PROBE_REQUEST_INVALID_URL
358
360
}
359
361
360
- if ( ! HTTPMethods . includes ( method ?. toUpperCase ( ) ?? 'GET' ) )
362
+ if ( ! HTTPMethods . has ( method ?. toUpperCase ( ) ?? 'GET' ) )
361
363
return PROBE_REQUEST_INVALID_METHOD
362
364
}
363
365
}
@@ -446,7 +448,7 @@ function validateRedisConfig(redisConfig?: Redis[]) {
446
448
host : Joi . alternatives ( )
447
449
. try ( Joi . string ( ) . hostname ( ) , Joi . string ( ) . ip ( ) )
448
450
. required ( ) ,
449
- port : Joi . number ( ) . min ( 0 ) . max ( 65536 ) . required ( ) ,
451
+ port : Joi . number ( ) . min ( 0 ) . max ( 65_536 ) . required ( ) ,
450
452
password : Joi . string ( ) ,
451
453
username : Joi . string ( ) ,
452
454
command : Joi . string ( ) ,
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ const responseChecker = (
54
54
return true
55
55
}
56
56
57
- return queryExpression ( res , alert . assertion )
57
+ return queryExpression ( res , alert . assertion || ( alert . query as string ) )
58
58
}
59
59
60
60
export default responseChecker
You can’t perform that action at this time.
0 commit comments