Skip to content

Commit 876b78b

Browse files
hyperpolymathclaude
andcommitted
fix(security): panic-attack P10 — MEDIUM fixes (HTTPS, mktemp, JSON 400, safe array)
- Upgrade HTTP→HTTPS in LeanTool.res, Page.res, Components.res, extract_nusmv.jl, extract_spin.jl, provision_corpora.sh - balance_smtlib_optimized.sh: replace hardcoded /tmp path with mktemp+trap - server.jl: wrap JSON3.read in try/catch; return 400 on malformed body - Daemon.res: Array.getUnsafe(i) → Array.get(i) with option handling Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent cfcf532 commit 876b78b

9 files changed

Lines changed: 25 additions & 12 deletions

File tree

balance_smtlib_optimized.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ REPLICA_DIR="$SMTLIB_DIR/replica"
1717
mkdir -p "$REPLICA_DIR"
1818

1919
# Get a list of all .smt2 files and store in a temporary file
20-
find "$SMTLIB_DIR" -name "*.smt2" > /tmp/smtlib_files.txt
20+
SMTLIB_TMPFILE=$(mktemp)
21+
trap 'rm -f "$SMTLIB_TMPFILE"' EXIT
22+
find "$SMTLIB_DIR" -name "*.smt2" > "$SMTLIB_TMPFILE"
2123

2224
# Read the list into an array
23-
mapfile -t FILES < /tmp/smtlib_files.txt
25+
mapfile -t FILES < "$SMTLIB_TMPFILE"
2426

2527
# Replicate files in batches to avoid timeout
2628
echo "Starting replication of $FILES_TO_ADD files..."

echidna-playground/src/Components.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ module TeamSection = {
121121
url: "",
122122
affiliations: [
123123
("CRI", "https://www.cri.ensmp.fr/"),
124-
("MINES ParisTech", "http://www.mines-paristech.eu"),
124+
("MINES ParisTech", "https://www.minesparis.psl.eu"),
125125
],
126126
},
127127
]

echidna-playground/src/Page.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ let primeExampleSection = (): string => {
6161
`We don't provide a Coq tutorial (yet), but as a showcase, we `,
6262
`display a proof of the infinitude of primes in Coq. The proof relies `,
6363
`in the Mathematical Components library by the `,
64-
Html.a(~href="http://ssr.msr-inria.inria.fr/", "MSR/Inria"),
64+
Html.a(~href="https://ssr.msr-inria.inria.fr/", "MSR/Inria"),
6565
` team led by Georges Gonthier, so our first step will be to load it and `,
6666
`set a few Coq options:`,
6767
]),

scripts/extract_nusmv.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env julia
22
# SPDX-License-Identifier: PMPL-1.0-or-later
33
# Extract NuSMV / nuXmv model-checker CTL/LTL properties.
4-
# Vendor: http://nusmv.fbk.eu/distrib/ (examples ship with distribution).
4+
# Vendor: https://nusmv.fbk.eu/distrib/ (examples ship with distribution).
55
using JSON3, Dates
66
include("extractor_save_common.jl")
77
const DIR = "external_corpora/nusmv"; const OUT = "training_data"; const START_ID = 2_600_000

scripts/extract_spin.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env julia
22
# SPDX-License-Identifier: PMPL-1.0-or-later
33
# Extract SPIN model-checker LTL properties from Promela models.
4-
# Vendor: http://spinroot.com/spin/Examples or nimble-code/Spin
4+
# Vendor: https://spinroot.com/spin/Examples or nimble-code/Spin
55
using JSON3, Dates
66
include("extractor_save_common.jl")
77
const DIR = "external_corpora/spin"; const OUT = "training_data"; const START_ID = 2_000_000

scripts/provision_corpora.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ CATALOGUE=(
9090
"seahorn|git|https://github.com/seahorn/seahorn"
9191
"spin|git|https://github.com/nimble-code/Spin"
9292
"prism|git|https://github.com/prismmodelchecker/prism-examples"
93-
"nusmv|skip|http://nusmv.fbk.eu/distrib/" # distro ships examples
93+
"nusmv|skip|https://nusmv.fbk.eu/distrib/" # distro ships examples
9494
"uppaal|skip|https://uppaal.org/documentation/" # commercial; examples gated
9595
"tlaplus_examples|git|https://github.com/tlaplus/Examples"
9696

src/julia/api/server.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ function handle_predict(req::HTTP.Request)
145145
state = get_state()
146146
state.request_count += 1
147147

148-
body = JSON3.read(String(req.body))
148+
body = try
149+
JSON3.read(String(req.body))
150+
catch e
151+
return HTTP.Response(400, JSON3.write(Dict("error" => "Invalid JSON: $(e)")))
152+
end
149153

150154
prover = parse_prover(get(body, :prover, "lean"))
151155
goal_text = get(body, :goal, "")
@@ -212,7 +216,11 @@ function handle_suggest(req::HTTP.Request)
212216
state = get_state()
213217
state.request_count += 1
214218

215-
body = JSON3.read(String(req.body))
219+
body = try
220+
JSON3.read(String(req.body))
221+
catch e
222+
return HTTP.Response(400, JSON3.write(Dict("error" => "Invalid JSON: $(e)")))
223+
end
216224
goal_text = get(body, :goal, "")
217225
prover_str = get(body, :prover, "lean")
218226
top_k = get(body, :top_k, 5)

src/provers/clients/LeanTool.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* ECHIDNA LeanTool Client
66
* Lean 4 theorem proving via OpenAI-compatible API.
77
* Uses the LeanTool OpenAI-compatible API server.
8-
* Demo: http://www.codeproofarena.com:8800/v1
8+
* Demo: https://www.codeproofarena.com:8800/v1
99
*/
1010

1111
/** Default LeanTool API endpoint */
12-
let leantoolDefaultEndpoint = "http://www.codeproofarena.com:8800/v1"
12+
let leantoolDefaultEndpoint = "https://www.codeproofarena.com:8800/v1"
1313

1414
/** Lean Playground endpoint for fallback */
1515
let leanPlaygroundUrl = "https://live.lean-lang.org"

src/provers/runners/Daemon.res

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ let emit = async (daemon: t, event: daemonEvent): unit => {
162162
let handlers = daemon.eventHandlers
163163
for i in 0 to Array.length(handlers) - 1 {
164164
try {
165-
await (handlers->Array.getUnsafe(i))(event)
165+
switch handlers->Array.get(i) {
166+
| Some(handler) => await handler(event)
167+
| None => ()
168+
}
166169
} catch {
167170
| exn => consoleError("[Daemon] Event handler error:", exn)
168171
}

0 commit comments

Comments
 (0)