mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-01 03:52:17 +03:00
Compare commits
1 Commits
docs/dedup
...
fix/codeql
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
528fba953d |
@@ -19,12 +19,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const KEY = process.env.NVIDIA_API_KEY ?? "";
|
const KEY = process.env.NVIDIA_API_KEY ?? "";
|
||||||
const BASE_URL = process.env.NVIDIA_BASE_URL || "https://integrate.api.nvidia.com/v1/chat/completions";
|
const BASE_URL =
|
||||||
|
process.env.NVIDIA_BASE_URL || "https://integrate.api.nvidia.com/v1/chat/completions";
|
||||||
const MODEL = process.env.NVIDIA_MODEL || "openai/gpt-oss-120b";
|
const MODEL = process.env.NVIDIA_MODEL || "openai/gpt-oss-120b";
|
||||||
|
|
||||||
// Neutralize CR/LF before logging so env-derived values (NVIDIA_MODEL, etc.)
|
// Neutralize CR/LF before logging so env-derived values (NVIDIA_MODEL, etc.)
|
||||||
// cannot forge extra log lines (S5145 log injection).
|
// cannot forge extra log lines (S5145 log injection). Also strip any raw
|
||||||
const line = (s = "") => console.log(String(s).replace(/[\r\n]+/g, " "));
|
// occurrence of the API key so an upstream error/response that echoes it
|
||||||
|
// back (e.g. inside err.stack or a validation result) never reaches the
|
||||||
|
// terminal in clear text (js/clear-text-logging, CWE-312/532).
|
||||||
|
const line = (s = "") => {
|
||||||
|
let out = String(s).replace(/[\r\n]+/g, " ");
|
||||||
|
if (KEY) out = out.split(KEY).join("[REDACTED]");
|
||||||
|
console.log(out);
|
||||||
|
};
|
||||||
const hr = () => line("─".repeat(72));
|
const hr = () => line("─".repeat(72));
|
||||||
|
|
||||||
function show(label: string, value: unknown) {
|
function show(label: string, value: unknown) {
|
||||||
@@ -52,8 +60,13 @@ async function partA() {
|
|||||||
});
|
});
|
||||||
line(" ✅ validateProviderApiKey retornou (sem crash):");
|
line(" ✅ validateProviderApiKey retornou (sem crash):");
|
||||||
show("resultado", result);
|
show("resultado", result);
|
||||||
if (typeof (result as any)?.error === "string" && (result as any).error.includes("startsWith")) {
|
if (
|
||||||
line(" ⚠️ A mensagem de erro contém 'startsWith' → crash CAPTURADO dentro do try/catch da validação.");
|
typeof (result as any)?.error === "string" &&
|
||||||
|
(result as any).error.includes("startsWith")
|
||||||
|
) {
|
||||||
|
line(
|
||||||
|
" ⚠️ A mensagem de erro contém 'startsWith' → crash CAPTURADO dentro do try/catch da validação."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
line(" ❌ validateProviderApiKey LANÇOU (crash não tratado):");
|
line(" ❌ validateProviderApiKey LANÇOU (crash não tratado):");
|
||||||
|
|||||||
Reference in New Issue
Block a user