From 8d80c423248bb35cdff448e91911362fd3c4277b Mon Sep 17 00:00:00 2001 From: nimec01 <24428341+nimec01@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:56:25 +0100 Subject: [PATCH 1/2] make globalTimeout be non-negative --- src/Prolog/Programming/Parser.hs | 9 ++++++--- test/ConfigSpec.hs | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Prolog/Programming/Parser.hs b/src/Prolog/Programming/Parser.hs index 84c616d..1762d07 100644 --- a/src/Prolog/Programming/Parser.hs +++ b/src/Prolog/Programming/Parser.hs @@ -211,9 +211,12 @@ instance FromJSON TaskConfig where parseJSON = withObject "TaskConfig" $ \v -> do rejectUnknownFields (recordFieldNames @TaskConfig) v - TaskConfig - <$> v .:? "globalTimeout" .!= 10000 - <*> v .:? "treeStyle" .!= QueryStyle + globalTO <- v .:? "globalTimeout" .!= 10000 + + when (globalTO < 0) $ fail "globalTimeout must be non-negative" + + TaskConfig globalTO + <$> v .:? "treeStyle" .!= QueryStyle <*> v .:? "includeTaskDefinitions" .!= Yes <*> v .:? "includeHiddenDefinitions" .!= Yes <*> v .:? "allowListPatternMatching" .!= True diff --git a/test/ConfigSpec.hs b/test/ConfigSpec.hs index 7432fc1..c3b5679 100644 --- a/test/ConfigSpec.hs +++ b/test/ConfigSpec.hs @@ -43,6 +43,12 @@ spec = describe "ExampleConfig" $ do result `shouldSatisfy` \case Right () -> False Left msg -> "Unknown or forbidden fields: globalTiimeout" `isInfixOf` msg -- no-spell-check + it "rejects config with negative globalTimeout" $ do + result <- + evaluateVerify $ "globalTimeout: -10000" ++ withoutConfigPart + result `shouldSatisfy` \case + Right () -> False + Left msg -> "globalTimeout must be non-negative" `isInfixOf` msg it "rejects code analysis configs with stage set to 'before-tests' and status unlike 'reject'" $ do result <- evaluateVerify $ From 192573ad407450f548597903a97ebae12e8b01c2 Mon Sep 17 00:00:00 2001 From: nimec01 <24428341+nimec01@users.noreply.github.com> Date: Fri, 20 Nov 2026 17:58:53 +0100 Subject: [PATCH 2/2] format spec --- test/ConfigSpec.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ConfigSpec.hs b/test/ConfigSpec.hs index c3b5679..e7bda2f 100644 --- a/test/ConfigSpec.hs +++ b/test/ConfigSpec.hs @@ -48,7 +48,7 @@ spec = describe "ExampleConfig" $ do evaluateVerify $ "globalTimeout: -10000" ++ withoutConfigPart result `shouldSatisfy` \case Right () -> False - Left msg -> "globalTimeout must be non-negative" `isInfixOf` msg + Left msg -> "globalTimeout must be non-negative" `isInfixOf` msg it "rejects code analysis configs with stage set to 'before-tests' and status unlike 'reject'" $ do result <- evaluateVerify $