T09 · Insecure Skill Coding Practices
- Location
ppt_doctor/check_environment.py:464- Finding
API Key Written to a Potentially Insecure or Symbolically Linked File
- Content
View full analysis
FillResult: missing: list[tuple[str, str]] = [ (name, desc) for name, desc in REQUIRED if not os.environ.get(name, "").strip() ] if not missing: return FillResult(written=False, path=None) if non_interactive: return FillResult(written=False, path=None) lines: list[str] = [] for name, desc in missing: value = input(f"{name} ({desc}): ").strip() if value: lines.append(f"{name}={value}") if not lines: return FillResult(written=False, path=None) env_path.parent.mkdir(parents=True, exist_ok=True) existing = env_path.read_text() if env_path.exists() else "" with env_path.open("w", encoding="utf-8") as f: if existing: f.write(existing) if not existing.endswith("\n"): f.write("\n") f.write("\n".join(lines) + "\n") return FillResult(written=True, path=env_path) ``` The package implementation duplicates the same behavior: ```python def interactive_fill_env(env_path: Path, non_interactive: bool = False) -> FillResult: missing: list[tuple[str, str]] = [ (name, desc) for name, desc in REQUIRED if not os.environ.get(name, "").strip() ] if not missing: return FillResult(written=False, path=None) if non_interactive: return FillResult(written=False, path=None) lines: list[str] = [] for name, desc in missing: value = input(f"{name} ({desc}): ").strip() if value: lines.append(f"{name}={value}") if not lines: return Fil ...[truncated 3171 chars]- Remediation
View remediation
