Skip to content

Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.

fix(security): address the first CodeQL scan

Agrici Daniel571318293530
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6bf71d2..242d03b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -66,6 +66,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
configuration. They now exit with "Nothing was changed". The PowerShell
writers check `$LASTEXITCODE`, so they no longer print "Done." after the
refusal.
+- The banana `setup_mcp.py` and `validate_setup.py` checks printed the first
+ eight characters of the Google AI key as well as the last four. They now
+ show only the last four. Found by CodeQL, now enabled on the repository.
- `keywordseverywhere_api.py` could echo the API key in an error when the
stored key had a trailing newline (pre-existing). Keys are stripped,
rejected if they contain control characters, and every error is redacted.
diff --git a/extensions/banana/scripts/setup_mcp.py b/extensions/banana/scripts/setup_mcp.py
index e421c33..789631e 100755
--- a/extensions/banana/scripts/setup_mcp.py
+++ b/extensions/banana/scripts/setup_mcp.py
@@ -65,7 +65,7 @@ def check_setup() -> bool:
if MCP_NAME in servers:
env = servers[MCP_NAME].get("env", {})
key = env.get("GOOGLE_AI_API_KEY", "")
- masked = key[:8] + "..." + key[-4:] if len(key) > 12 else "(not set)"
+ masked = "..." + key[-4:] if len(key) > 12 else "(not set)"
print(f"MCP server '{MCP_NAME}' is configured.")
print(f" Package: {MCP_PACKAGE}")
print(f" API Key: {masked}")
diff --git a/extensions/banana/scripts/validate_setup.py b/extensions/banana/scripts/validate_setup.py
index d2a7afb..f620069 100755
--- a/extensions/banana/scripts/validate_setup.py
+++ b/extensions/banana/scripts/validate_setup.py
@@ -96,7 +96,7 @@ def main() -> int:
results.append(check(
"GOOGLE_AI_API_KEY is set",
bool(key),
- f"{key[:8]}...{key[-4:]}" if len(key) > 12 else "(empty or short)",
+ f"...{key[-4:]}" if len(key) > 12 else "(empty or short)",
))
# 7. Model configured
diff --git a/scripts/nlp_analyze.py b/scripts/nlp_analyze.py
index f09937b..f87ad00 100644
--- a/scripts/nlp_analyze.py
+++ b/scripts/nlp_analyze.py
@@ -281,8 +281,8 @@ def analyze_url(
except ImportError:
# Fallback: regex-based text extraction
import re
- text = re.sub(r"<script[^>]*>.*?</script>", "", html, flags=re.DOTALL | re.IGNORECASE)
- text = re.sub(r"<style[^>]*>.*?</style>", "", text, flags=re.DOTALL | re.IGNORECASE)
+ text = re.sub(r"<script[^>]*>.*?</script\s*>", "", html, flags=re.DOTALL | re.IGNORECASE)
+ text = re.sub(r"<style[^>]*>.*?</style\s*>", "", text, flags=re.DOTALL | re.IGNORECASE)
text = re.sub(r"<[^>]+>", " ", text)
text = re.sub(r"\s+", " ", text).strip()
diff --git a/tests/test_banana_key_masking.py b/tests/test_banana_key_masking.py
new file mode 100644
index 0000000..7ad6f4b
--- /dev/null
+++ b/tests/test_banana_key_masking.py
@@ -0,0 +1,46 @@
+"""The banana setup checks show only the last four characters of the key.
+
+They used to print the first eight as well, which for a Google AI key is the
+fixed prefix plus four characters of the secret (CodeQL
+py/clear-text-logging-sensitive-data).
+"""
+
+from __future__ import annotations
+
+import importlib.util
+import json
+import sys
+from pathlib import Path
+
+import pytest
+
+REPO_ROOT = Path(__file__).resolve().parents[1]
+FAKE_KEY = "AIzaSyFAKEFAKEFAKEFAKEFAKEFAKEFAKEwxyz"
+
+
+def _load(monkeypatch, home: Path, name: str):
+ monkeypatch.setenv("HOME", str(home))
+ monkeypatch.setenv("USERPROFILE", str(home))
+ (home / ".claude.json").write_text(json.dumps({"mcpServers": {"nanobanana-mcp": {
+ "command": "npx", "args": ["-y", "@ycse/nanobanana-mcp"],
+ "env": {"GOOGLE_AI_API_KEY": FAKE_KEY},
+ }}}))
+ spec = importlib.util.spec_from_file_location(
+ f"banana_{name}", REPO_ROOT / f"extensions/banana/scripts/{name}.py"
+ )
+ module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(module)
+ return module
+
+
[email protected]("name,call", [
+ ("setup_mcp", lambda m: m.check_setup()),
+ ("validate_setup", lambda m: m.main()),
+])
+def test_only_the_last_four_key_characters_are_shown(monkeypatch, tmp_path, capsys, name, call):
+ module = _load(monkeypatch, tmp_path, name)
+ monkeypatch.setattr(sys, "argv", [name])
+ call(module)
+ out = capsys.readouterr().out
+ assert "...wxyz" in out
+ assert FAKE_KEY[:8] not in out