Ask the AI copilot a security question.
(
question: str = typer.Argument(..., help="Question to ask about security"),
target: Optional[str] = typer.Option(None, "--target", "-t", help="Target to scan first"),
provider: str = typer.Option("anthropic", "--provider", "-p", help="LLM provider (anthropic/openai/ollama/qwen/llama3/mistral)"),
model: Optional[str] = typer.Option(None, "--model", "-m", help="Model name"),
base_url: Optional[str] = typer.Option(None, "--base-url", "-b", help="Base URL for ollama or custom API"),
)
| 715 | console.print("[dim]For cloud: Set SECSUITE_ANTHROPIC_API_KEY or SECSUITE_OPENAI_API_KEY[/dim]") |
| 716 | console.print("[dim]For local: Use -p ollama -m <model> (requires Ollama running)[/dim]") |
| 717 | except ImportError as e: |
| 718 | console.print(f"[red]Missing package: {e}[/red]") |
| 719 | except Exception as e: |
| 720 | console.print(f"[red]Error: {e}[/red]") |
| 721 | if "ollama" in provider.lower(): |
| 722 | console.print("[dim]Make sure Ollama is running: ollama serve[/dim]") |
| 723 | |
| 724 | |
| 725 | @ai_app.command("ask") |
| 726 | def ai_ask( |
| 727 | question: str = typer.Argument(..., help="Question to ask about security"), |
| 728 | target: str | None = typer.Option(None, "--target", "-t", help="Target to scan first"), |
| 729 | provider: str = typer.Option("anthropic", "--provider", "-p", help="LLM provider (anthropic/openai/ollama/qwen/llama3/mistral)"), |
| 730 | model: str | None = typer.Option(None, "--model", "-m", help="Model name"), |
| 731 | base_url: str | None = typer.Option(None, "--base-url", "-b", help="Base URL for ollama or custom API"), |
| 732 | ): |
| 733 | """Ask the AI copilot a security question.""" |
| 734 | setup_logging() |
| 735 | |
| 736 | try: |
| 737 | from modules.ai import SecurityCopilot |
| 738 | |
| 739 | copilot = SecurityCopilot(provider=provider, model=model, base_url=base_url) |
| 740 | |
| 741 | # If target provided, run quick scan first |
| 742 | if target: |
| 743 | console.print(f"[dim]Scanning {target}...[/dim]") |
| 744 | results = _collect_scan_results(target, ["dns", "headers", "tech"]) |
| 745 | copilot.load_scan_results(results) |
| 746 | |
| 747 | console.print(f"[cyan]Question:[/cyan] {question}") |
| 748 | console.print() |
| 749 | |
| 750 | response = run_async(copilot.ask(question)) |
| 751 | console.print(Panel(response, title="[bold magenta]AI Response[/bold magenta]", border_style="magenta")) |
| 752 |
nothing calls this directly
no test coverage detected