cycode 3.27.1.dev11__tar.gz → 3.27.2.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/PKG-INFO +2 -1
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/README.md +1 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/__init__.py +1 -1
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/ides/base.py +13 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/ides/copilot.py +144 -5
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/scan/handlers.py +47 -18
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/scan/payload.py +7 -0
- cycode-3.27.2.dev1/cycode/cli/apps/ai_guardrails/scan/prompt_images.py +184 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/scan/scan_command.py +15 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/scan/utils.py +15 -7
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/models/in_memory_zip.py +4 -5
- cycode-3.27.2.dev1/cycode/cli/files_collector/sca/maven/restore_gradle_dependencies.py +136 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/models.py +13 -2
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/scan_batch.py +2 -1
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/pyproject.toml +1 -1
- cycode-3.27.1.dev11/cycode/cli/files_collector/sca/maven/restore_gradle_dependencies.py +0 -81
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/LICENCE +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/__main__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/app.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/activation_manager.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/command_utils.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/consts.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/hooks_manager.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/ides/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/ides/_plugin_utils.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/ides/_skill_utils.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/ides/claude_code.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/ides/codex.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/ides/cursor.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/install_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/scan/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/scan/consts.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/scan/detach.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/scan/guardrail_config.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/scan/mcp_server_status.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/scan/policy.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/scan/types.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/session_start_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/status_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/uninstall_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_remediation/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_remediation/ai_remediation_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_remediation/apply_fix.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_remediation/print_remediation.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/api/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/api/api_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/api/openapi_spec.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/auth/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/auth/auth_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/auth/auth_common.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/auth/auth_manager.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/auth/models.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/configure/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/configure/configure_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/configure/consts.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/configure/messages.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/configure/prompts.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ignore/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ignore/ignore_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/mcp/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/mcp/mcp_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report/report_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report/sbom/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report/sbom/common.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report/sbom/path/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report/sbom/path/path_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report/sbom/repository_url/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report/sbom/repository_url/repository_url_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report/sbom/sbom_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report/sbom/sbom_report_file.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report_import/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report_import/report_import_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report_import/sbom/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/report_import/sbom/sbom_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/sca_options.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/aggregation_report.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/code_scanner.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/commit_history/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/commit_history/commit_history_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/commit_range_scanner.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/detection_excluder.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/path/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/path/path_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/pre_commit/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/pre_commit/pre_commit_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/pre_push/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/pre_push/pre_push_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/pre_receive/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/pre_receive/pre_receive_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/remote_url_resolver.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/repository/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/repository/repository_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/scan_ci/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/scan_ci/ci_integrations.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/scan_ci/scan_ci_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/scan_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/scan_parameters.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/scan/scan_result.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/status/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/status/get_cli_status.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/status/models.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/status/status_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/status/version_command.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/cli_types.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/config.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/console.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/consts.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/exceptions/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/exceptions/custom_exceptions.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/exceptions/handle_ai_remediation_errors.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/exceptions/handle_auth_errors.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/exceptions/handle_errors.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/exceptions/handle_report_sbom_errors.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/exceptions/handle_scan_errors.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/commit_range_documents.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/documents_walk_ignore.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/file_excluder.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/iac/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/iac/tf_content_generator.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/models/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/path_documents.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/repository_documents.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/base_restore_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/go/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/go/restore_go_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/maven/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/maven/restore_maven_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/npm/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/npm/restore_bun_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/npm/restore_deno_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/npm/restore_npm_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/npm/restore_pnpm_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/npm/restore_yarn_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/npm/workspace/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/npm/workspace/coverage.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/npm/workspace/files.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/npm/workspace/globs.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/npm/workspace/names.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/npm/workspace/resolvers.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/nuget/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/nuget/restore_nuget_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/php/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/php/restore_composer_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/python/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/python/restore_pip_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/python/restore_pipenv_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/python/restore_poetry_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/python/restore_uv_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/ruby/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/ruby/restore_ruby_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/sbt/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/sbt/restore_sbt_dependencies.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/sca/sca_file_collector.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/walk_ignore.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/files_collector/zip_documents.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/logger.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/main.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/console_printer.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/json_printer.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/printer_base.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/rich_printer.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/tables/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/tables/sca_table_printer.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/tables/table.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/tables/table_models.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/tables/table_printer.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/tables/table_printer_base.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/text_printer.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/utils/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/utils/code_snippet_syntax.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/utils/detection_data.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/utils/detection_ordering/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/utils/detection_ordering/common_ordering.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/utils/detection_ordering/sca_ordering.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/utils/rich_helpers.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/utils/sca_ossf.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/printers/utils/sca_policy_details.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/user_settings/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/user_settings/base_file_manager.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/user_settings/config_file_manager.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/user_settings/configuration_manager.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/user_settings/credentials_manager.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/user_settings/jwt_creator.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/binary_utils.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/enum_utils.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/get_api_client.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/git_proxy.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/host_info.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/ignore_utils.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/jwt_utils.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/path_utils.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/progress_bar.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/scan_utils.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/shell_executor.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/string_utils.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/task_timer.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/trust_store.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/url_utils.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/version_checker.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/utils/yaml_utils.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/config.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/__init__.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/ai_security_manager_client.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/ai_security_manager_service_config.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/auth_client.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/base_token_auth_client.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/cli_activation_client.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/client_creator.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/config.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/config_dev.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/cycode_client.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/cycode_client_base.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/cycode_dev_based_client.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/cycode_oidc_based_client.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/cycode_token_based_client.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/headers.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/import_sbom_client.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/logger.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/models.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/report_client.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/scan_client.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cyclient/scan_config_base.py +0 -0
- {cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/logger.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cycode
|
|
3
|
-
Version: 3.27.
|
|
3
|
+
Version: 3.27.2.dev1
|
|
4
4
|
Summary: Boost security in your dev lifecycle via SAST, SCA, Secrets & IaC scanning.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENCE
|
|
@@ -800,6 +800,7 @@ prompts, files the agent reads, and MCP tool arguments are scanned for secrets b
|
|
|
800
800
|
|
|
801
801
|
Scanning happens server-side, so the scanned content leaves the machine: the prompt text, the contents of
|
|
802
802
|
files the agent reads, and MCP tool arguments are sent to your Cycode tenant to be checked for secrets.
|
|
803
|
+
For GitHub Copilot, PNG and JPEG images attached to a prompt are sent along with its text.
|
|
803
804
|
|
|
804
805
|
Each event is also reported with context about the developer and the machine, so a finding can be attributed
|
|
805
806
|
to the device and user it came from. Some of this is personal data:
|
|
@@ -755,6 +755,7 @@ prompts, files the agent reads, and MCP tool arguments are scanned for secrets b
|
|
|
755
755
|
|
|
756
756
|
Scanning happens server-side, so the scanned content leaves the machine: the prompt text, the contents of
|
|
757
757
|
files the agent reads, and MCP tool arguments are sent to your Cycode tenant to be checked for secrets.
|
|
758
|
+
For GitHub Copilot, PNG and JPEG images attached to a prompt are sent along with its text.
|
|
758
759
|
|
|
759
760
|
Each event is also reported with context about the developer and the machine, so a finding can be attributed
|
|
760
761
|
to the device and user it came from. Some of this is personal data:
|
|
@@ -5,4 +5,4 @@ import time as _time
|
|
|
5
5
|
# end-to-end scan duration from the moment the user actually triggered it.
|
|
6
6
|
_BOOT_WALL: float = _time.time()
|
|
7
7
|
|
|
8
|
-
__version__ = '3.27.
|
|
8
|
+
__version__ = '3.27.2.dev1' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
|
|
@@ -21,6 +21,7 @@ from pathlib import Path
|
|
|
21
21
|
from typing import ClassVar
|
|
22
22
|
|
|
23
23
|
from cycode.cli.apps.ai_guardrails.scan.payload import AIHookPayload
|
|
24
|
+
from cycode.cli.apps.ai_guardrails.scan.prompt_images import PromptImage
|
|
24
25
|
from cycode.cli.apps.ai_guardrails.scan.types import AiHookEventType
|
|
25
26
|
|
|
26
27
|
|
|
@@ -159,6 +160,18 @@ class IDE(ABC):
|
|
|
159
160
|
def parse_hook_payload(self, raw_payload: dict) -> AIHookPayload:
|
|
160
161
|
"""Normalize a raw stdin payload into the canonical ``AIHookPayload``."""
|
|
161
162
|
|
|
163
|
+
def collect_prompt_images(self, raw_payload: dict) -> list[PromptImage]:
|
|
164
|
+
"""Return the images attached to a prompt, read once, to scan along with its text.
|
|
165
|
+
|
|
166
|
+
``scan_command`` calls it for every prompt event, only in the process that runs the scan
|
|
167
|
+
(never in a parent about to detach): collecting may move per-session state forward, so a
|
|
168
|
+
second call for the same prompt finds nothing. The server decides whether to scan them.
|
|
169
|
+
|
|
170
|
+
Default: ``[]`` (attachments are out of the hook's reach). Override for IDEs that leave
|
|
171
|
+
them on disk.
|
|
172
|
+
"""
|
|
173
|
+
return []
|
|
174
|
+
|
|
162
175
|
@abstractmethod
|
|
163
176
|
def build_hook_response(self, decision: HookDecision) -> dict:
|
|
164
177
|
"""Translate a canonical ``HookDecision`` into the IDE-specific JSON.
|
|
@@ -19,13 +19,21 @@ runtime uses ``Read``/``path`` and ``<server>-<tool>`` — so both are accepted.
|
|
|
19
19
|
Copilot hooks have no matchers, so ``PreToolUse`` fires for every tool; tools we
|
|
20
20
|
don't scan pass through as raw event names, which match no handler and allow
|
|
21
21
|
immediately.
|
|
22
|
+
|
|
23
|
+
A ``UserPromptSubmit`` payload carries the prompt text only, never its attachments,
|
|
24
|
+
but by the time the hook runs Copilot has saved every attached image to disk; see
|
|
25
|
+
``Copilot.collect_prompt_images`` for where each runtime puts them.
|
|
22
26
|
"""
|
|
23
27
|
|
|
24
28
|
import json
|
|
25
29
|
import os
|
|
26
30
|
import platform
|
|
27
31
|
import re
|
|
32
|
+
import sqlite3
|
|
33
|
+
import tempfile
|
|
34
|
+
import time
|
|
28
35
|
from collections.abc import Iterable
|
|
36
|
+
from contextlib import closing
|
|
29
37
|
from pathlib import Path
|
|
30
38
|
from typing import ClassVar
|
|
31
39
|
from urllib.parse import urlparse
|
|
@@ -40,6 +48,13 @@ from cycode.cli.apps.ai_guardrails.ides._plugin_utils import (
|
|
|
40
48
|
from cycode.cli.apps.ai_guardrails.ides._skill_utils import walk_plugin_skills, walk_skill_dirs
|
|
41
49
|
from cycode.cli.apps.ai_guardrails.ides.base import IDE, DecisionAction, HookDecision
|
|
42
50
|
from cycode.cli.apps.ai_guardrails.scan.payload import AIHookPayload
|
|
51
|
+
from cycode.cli.apps.ai_guardrails.scan.prompt_images import (
|
|
52
|
+
PromptImage,
|
|
53
|
+
get_prompt_mark,
|
|
54
|
+
modified_between,
|
|
55
|
+
save_prompt_mark,
|
|
56
|
+
select_prompt_images,
|
|
57
|
+
)
|
|
43
58
|
from cycode.cli.apps.ai_guardrails.scan.types import AiHookEventType
|
|
44
59
|
from cycode.logger import get_logger
|
|
45
60
|
|
|
@@ -97,6 +112,26 @@ _PLUGIN_MANIFEST_LOCATIONS = (
|
|
|
97
112
|
_SCAN_COMMAND = f'{CYCODE_SCAN_PROMPT_COMMAND} --ide copilot'
|
|
98
113
|
_SESSION_START_COMMAND = f'{CYCODE_SESSION_START_COMMAND} --ide copilot'
|
|
99
114
|
|
|
115
|
+
# Copilot CLI leaves an `@path` mention in the prompt as typed: quoted, with
|
|
116
|
+
# backslash-escaped spaces (a file dragged into a terminal), or plain up to the next
|
|
117
|
+
# whitespace. Never mid-word, so an email address is not a mention. A lookahead, so
|
|
118
|
+
# every `@` is read on its own: a quote left open must not swallow the mentions after
|
|
119
|
+
# it, and a quoted path never spans lines.
|
|
120
|
+
_MENTION_PATTERN = re.compile(r'(?<!\S)@(?=("[^"\n]+"|\'[^\'\n]+\'|(?:\\ |\S)+))')
|
|
121
|
+
_MENTION_TRAILING_PUNCTUATION = '.,;:!?)]}'
|
|
122
|
+
# Copilot CLI replaces a pasted image with this placeholder, naming the file it saved
|
|
123
|
+
# in the temp directory.
|
|
124
|
+
_PASTED_IMAGE_PATTERN = re.compile(r'\[image:\s*([^\]\r\n]+?)\s*\]')
|
|
125
|
+
|
|
126
|
+
# VS Code (stable and Insiders) agent sessions copy a prompt's attachments into the
|
|
127
|
+
# chat's session data when it is sent. That folder is named after VS Code's chat id, not
|
|
128
|
+
# the hook's session_id; the chat's session database records the agent runtime's session
|
|
129
|
+
# id, which is the hook's, under one of these keys.
|
|
130
|
+
_VSCODE_PRODUCT_NAMES = ('Code', 'Code - Insiders')
|
|
131
|
+
_VSCODE_ATTACHMENT_COPIES_GLOB = 'agentSessionData/*/attachments/*/*'
|
|
132
|
+
_VSCODE_CHAT_DB_NAME = 'session.db'
|
|
133
|
+
_VSCODE_CHAT_SESSION_KEYS = ('defaultChatProviderData', 'agentHost.chatProviderData')
|
|
134
|
+
|
|
100
135
|
|
|
101
136
|
def _copilot_home() -> Path:
|
|
102
137
|
"""Resolve Copilot's user-scope home directory (honors ``$COPILOT_HOME``)."""
|
|
@@ -118,13 +153,18 @@ def _vscode_agent_plugins_dir() -> Path:
|
|
|
118
153
|
return Path.home() / '.vscode' / 'agent-plugins'
|
|
119
154
|
|
|
120
155
|
|
|
121
|
-
def
|
|
122
|
-
"""Per-platform VS Code user
|
|
156
|
+
def _vscode_user_data_dir(product_name: str = 'Code') -> Path:
|
|
157
|
+
"""Per-platform VS Code user data directory; ``product_name`` is 'Code' or 'Code - Insiders'."""
|
|
123
158
|
if platform.system() == 'Darwin':
|
|
124
|
-
return Path.home() / 'Library' / 'Application Support' /
|
|
159
|
+
return Path.home() / 'Library' / 'Application Support' / product_name
|
|
125
160
|
if platform.system() == 'Windows':
|
|
126
|
-
return Path.home() / 'AppData' / 'Roaming' /
|
|
127
|
-
return Path.home() / '.config' /
|
|
161
|
+
return Path.home() / 'AppData' / 'Roaming' / product_name
|
|
162
|
+
return Path.home() / '.config' / product_name
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def _vscode_user_dir() -> Path:
|
|
166
|
+
"""Per-platform VS Code user settings directory."""
|
|
167
|
+
return _vscode_user_data_dir() / 'User'
|
|
128
168
|
|
|
129
169
|
|
|
130
170
|
def _vscode_mcp_config_path() -> Path:
|
|
@@ -380,6 +420,80 @@ def split_mcp_tool_name(tool_name: str, server_names: Iterable[str]) -> tuple[st
|
|
|
380
420
|
return None, rest or None
|
|
381
421
|
|
|
382
422
|
|
|
423
|
+
# --- prompt images ------------------------------------------------------------------
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
def _mentioned_files(prompt: str, cwd: str | None) -> list[Path]:
|
|
427
|
+
"""Existing files named by `@` mentions, resolved against the hook's cwd."""
|
|
428
|
+
base = Path(cwd) if cwd else Path()
|
|
429
|
+
files = []
|
|
430
|
+
for match in _MENTION_PATTERN.finditer(prompt):
|
|
431
|
+
token = match.group(1)
|
|
432
|
+
if len(token) > 1 and token[0] == token[-1] and token[0] in '"\'':
|
|
433
|
+
spellings = [token[1:-1]]
|
|
434
|
+
else:
|
|
435
|
+
if os.sep == '/':
|
|
436
|
+
token = token.replace('\\ ', ' ')
|
|
437
|
+
# The mention may end a sentence ("look at @shot.png.")
|
|
438
|
+
spellings = [token, token.rstrip(_MENTION_TRAILING_PUNCTUATION)]
|
|
439
|
+
for spelling in spellings:
|
|
440
|
+
path = base / os.path.expanduser(spelling)
|
|
441
|
+
if os.path.isfile(path):
|
|
442
|
+
files.append(path)
|
|
443
|
+
break
|
|
444
|
+
return files
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
def _pasted_cli_images(prompt: str) -> list[Path]:
|
|
448
|
+
"""Images pasted into Copilot CLI, saved in the temp directory its placeholder names."""
|
|
449
|
+
temp_dir = Path(tempfile.gettempdir())
|
|
450
|
+
# The base name only: the placeholder is prompt text, so it must not lead outside the temp directory
|
|
451
|
+
return [temp_dir / os.path.basename(name) for name in _PASTED_IMAGE_PATTERN.findall(prompt)]
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
def _vscode_chat_session_id(chat_dir: Path) -> str | None:
|
|
455
|
+
"""The agent runtime's session id that VS Code recorded for a chat, or None."""
|
|
456
|
+
db_path = chat_dir / _VSCODE_CHAT_DB_NAME
|
|
457
|
+
if not db_path.is_file():
|
|
458
|
+
return None
|
|
459
|
+
placeholders = ', '.join('?' * len(_VSCODE_CHAT_SESSION_KEYS))
|
|
460
|
+
query = f'SELECT value FROM session_metadata WHERE key IN ({placeholders})' # noqa: S608
|
|
461
|
+
try:
|
|
462
|
+
# Read-only: VS Code keeps writing to the file while the chat is open
|
|
463
|
+
with closing(sqlite3.connect(f'{db_path.resolve().as_uri()}?mode=ro', uri=True, timeout=1)) as connection:
|
|
464
|
+
values = [value for (value,) in connection.execute(query, _VSCODE_CHAT_SESSION_KEYS)]
|
|
465
|
+
except sqlite3.Error as e:
|
|
466
|
+
logger.debug('Failed to read a VS Code chat session database, %s', {'path': str(db_path)}, exc_info=e)
|
|
467
|
+
return None
|
|
468
|
+
for value in values:
|
|
469
|
+
try:
|
|
470
|
+
session_id = json.loads(value).get('sdkSessionId')
|
|
471
|
+
except (TypeError, ValueError, AttributeError):
|
|
472
|
+
continue
|
|
473
|
+
if isinstance(session_id, str) and session_id:
|
|
474
|
+
return session_id
|
|
475
|
+
return None
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
def _vscode_saved_attachments(session_id: str | None, since: float, until: float) -> list[Path]:
|
|
479
|
+
"""Attachment files VS Code saved in ``[since, until)`` for this session's chat.
|
|
480
|
+
|
|
481
|
+
Other chats' attachments, in any window, never count. A prompt with no VS Code chat
|
|
482
|
+
of its own (Copilot CLI, or VS Code's local chat) gets none.
|
|
483
|
+
"""
|
|
484
|
+
if not session_id:
|
|
485
|
+
return []
|
|
486
|
+
copies: list[Path] = []
|
|
487
|
+
for product_name in _VSCODE_PRODUCT_NAMES:
|
|
488
|
+
copies.extend(_vscode_user_data_dir(product_name).glob(_VSCODE_ATTACHMENT_COPIES_GLOB))
|
|
489
|
+
recent = modified_between(copies, since, until)
|
|
490
|
+
# <chat id>/attachments/<attachment id>/<file>
|
|
491
|
+
chats_of_this_session = {
|
|
492
|
+
chat_dir for chat_dir in {path.parents[2] for path in recent} if _vscode_chat_session_id(chat_dir) == session_id
|
|
493
|
+
}
|
|
494
|
+
return [path for path in recent if path.parents[2] in chats_of_this_session]
|
|
495
|
+
|
|
496
|
+
|
|
383
497
|
class Copilot(IDE):
|
|
384
498
|
name: ClassVar[str] = 'copilot'
|
|
385
499
|
display_name: ClassVar[str] = 'GitHub Copilot'
|
|
@@ -450,6 +564,31 @@ class Copilot(IDE):
|
|
|
450
564
|
mcp_arguments=mcp_arguments,
|
|
451
565
|
)
|
|
452
566
|
|
|
567
|
+
def collect_prompt_images(self, raw_payload: dict) -> list[PromptImage]:
|
|
568
|
+
"""Images attached to a prompt, found where Copilot saved them before the hook ran.
|
|
569
|
+
|
|
570
|
+
Copilot CLI names its attachments in the prompt: an `@path` mention as typed, or
|
|
571
|
+
a pasted image's placeholder. VS Code names none, so its attachments are the files
|
|
572
|
+
it saved for this session's chat since the session's previous prompt (see
|
|
573
|
+
prompt_images).
|
|
574
|
+
"""
|
|
575
|
+
session_id = raw_payload.get('session_id')
|
|
576
|
+
prompt = raw_payload.get('prompt') or ''
|
|
577
|
+
now = time.time()
|
|
578
|
+
since = get_prompt_mark(session_id, now)
|
|
579
|
+
|
|
580
|
+
images = select_prompt_images(
|
|
581
|
+
[
|
|
582
|
+
*_mentioned_files(prompt, raw_payload.get('cwd')),
|
|
583
|
+
*_pasted_cli_images(prompt),
|
|
584
|
+
*_vscode_saved_attachments(session_id, since, now),
|
|
585
|
+
]
|
|
586
|
+
)
|
|
587
|
+
save_prompt_mark(session_id, now)
|
|
588
|
+
|
|
589
|
+
logger.debug('Collected prompt images, %s', {'images_count': len(images), 'since': since})
|
|
590
|
+
return images
|
|
591
|
+
|
|
453
592
|
def build_hook_response(self, decision: HookDecision) -> dict:
|
|
454
593
|
if decision.action == DecisionAction.ALLOW:
|
|
455
594
|
# Neutral allow: {} means "no objection", leaving VS Code's own
|
|
@@ -12,7 +12,7 @@ import json
|
|
|
12
12
|
import os
|
|
13
13
|
import sys
|
|
14
14
|
import threading
|
|
15
|
-
from collections.abc import Callable
|
|
15
|
+
from collections.abc import Callable, Sequence
|
|
16
16
|
from dataclasses import dataclass
|
|
17
17
|
from gettext import ngettext
|
|
18
18
|
from typing import TYPE_CHECKING, Any, NamedTuple
|
|
@@ -27,6 +27,7 @@ from cycode.cli.apps.ai_guardrails.ides.base import HookDecision
|
|
|
27
27
|
from cycode.cli.apps.ai_guardrails.scan.mcp_server_status import is_enforced, load_mcp_server_statuses
|
|
28
28
|
from cycode.cli.apps.ai_guardrails.scan.payload import AIHookPayload
|
|
29
29
|
from cycode.cli.apps.ai_guardrails.scan.policy import get_policy_value
|
|
30
|
+
from cycode.cli.apps.ai_guardrails.scan.prompt_images import PromptImage
|
|
30
31
|
from cycode.cli.apps.ai_guardrails.scan.types import (
|
|
31
32
|
SECRETS_BLOCK_REASON_BY_EVENT_TYPE,
|
|
32
33
|
AiHookEventType,
|
|
@@ -47,6 +48,8 @@ logger = get_logger('AI Guardrails')
|
|
|
47
48
|
|
|
48
49
|
HandlerFn = Callable[[typer.Context, AIHookPayload, dict], HookDecision]
|
|
49
50
|
|
|
51
|
+
_TEXT_DOCUMENT_NAME = 'prompt-content.txt'
|
|
52
|
+
|
|
50
53
|
|
|
51
54
|
def _ignore_commands(shas: tuple[str, ...]) -> list[str]:
|
|
52
55
|
"""Ready-to-run ignore commands, one per finding, in the order the findings are listed.
|
|
@@ -112,7 +115,7 @@ def _parse_verdict(verdict: str | None) -> GuardrailsMode | None:
|
|
|
112
115
|
|
|
113
116
|
|
|
114
117
|
def handle_before_submit_prompt(ctx: typer.Context, payload: AIHookPayload, policy: dict) -> HookDecision:
|
|
115
|
-
"""Scan prompt text for secrets before it's sent to the AI model."""
|
|
118
|
+
"""Scan prompt text, and the images attached to it, for secrets before it's sent to the AI model."""
|
|
116
119
|
ai_client = ctx.obj['ai_security_client']
|
|
117
120
|
|
|
118
121
|
prompt = payload.prompt or ''
|
|
@@ -127,11 +130,7 @@ def handle_before_submit_prompt(ctx: typer.Context, payload: AIHookPayload, poli
|
|
|
127
130
|
|
|
128
131
|
try:
|
|
129
132
|
scan_outcome = _scan_text_for_secrets(
|
|
130
|
-
ctx,
|
|
131
|
-
clipped,
|
|
132
|
-
timeout_ms,
|
|
133
|
-
payload=payload,
|
|
134
|
-
event_type=AiHookEventType.PROMPT,
|
|
133
|
+
ctx, clipped, timeout_ms, payload=payload, event_type=AiHookEventType.PROMPT, images=payload.images
|
|
135
134
|
)
|
|
136
135
|
scan_id = scan_outcome.scan_id
|
|
137
136
|
|
|
@@ -538,22 +537,53 @@ def _perform_scan(
|
|
|
538
537
|
)
|
|
539
538
|
|
|
540
539
|
|
|
541
|
-
def
|
|
540
|
+
def _scan_documents_for_secrets(
|
|
542
541
|
ctx: typer.Context,
|
|
543
|
-
|
|
542
|
+
documents: list[Document],
|
|
544
543
|
timeout_ms: int,
|
|
545
544
|
payload: AIHookPayload,
|
|
546
545
|
event_type: AiHookEventType,
|
|
546
|
+
paths: tuple[str, ...] | None = None,
|
|
547
547
|
) -> ScanOutcome:
|
|
548
|
-
"""Scan
|
|
549
|
-
if not
|
|
548
|
+
"""Scan in-memory documents for secrets, all in one scan; no documents means no scan."""
|
|
549
|
+
if not documents:
|
|
550
550
|
return NO_SCAN
|
|
551
551
|
|
|
552
|
-
document = Document(path='prompt-content.txt', content=text, is_git_diff_format=False)
|
|
553
552
|
scan_ctx = _setup_scan_context(ctx)
|
|
554
553
|
timeout_seconds = timeout_ms / 1000.0
|
|
555
|
-
scan_parameters = build_ai_guardrails_scan_parameters(scan_ctx,
|
|
556
|
-
return _perform_scan(scan_ctx,
|
|
554
|
+
scan_parameters = build_ai_guardrails_scan_parameters(scan_ctx, paths, payload, event_type)
|
|
555
|
+
return _perform_scan(scan_ctx, documents, scan_parameters, timeout_seconds)
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
def _image_documents(images: Sequence[PromptImage]) -> list[Document]:
|
|
559
|
+
"""One bytes document per attached image.
|
|
560
|
+
|
|
561
|
+
The entry name keeps an image extension because the server picks the files to scan by extension as well as
|
|
562
|
+
signature. The original path stays on the document, to name the image in the block message.
|
|
563
|
+
"""
|
|
564
|
+
return [
|
|
565
|
+
Document(
|
|
566
|
+
path=f'image-{index}-{image.file_name}',
|
|
567
|
+
content=image.content,
|
|
568
|
+
is_git_diff_format=False,
|
|
569
|
+
absolute_path=image.path,
|
|
570
|
+
)
|
|
571
|
+
for index, image in enumerate(images, start=1)
|
|
572
|
+
]
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
def _scan_text_for_secrets(
|
|
576
|
+
ctx: typer.Context,
|
|
577
|
+
text: str,
|
|
578
|
+
timeout_ms: int,
|
|
579
|
+
payload: AIHookPayload,
|
|
580
|
+
event_type: AiHookEventType,
|
|
581
|
+
images: Sequence[PromptImage] = (),
|
|
582
|
+
) -> ScanOutcome:
|
|
583
|
+
"""Scan text, and the images attached with it, for secrets in one scan."""
|
|
584
|
+
documents = [Document(path=_TEXT_DOCUMENT_NAME, content=text, is_git_diff_format=False)] if text else []
|
|
585
|
+
documents.extend(_image_documents(images))
|
|
586
|
+
return _scan_documents_for_secrets(ctx, documents, timeout_ms, payload, event_type)
|
|
557
587
|
|
|
558
588
|
|
|
559
589
|
def _scan_path_for_secrets(
|
|
@@ -576,9 +606,8 @@ def _scan_path_for_secrets(
|
|
|
576
606
|
content = f.read(max_bytes)
|
|
577
607
|
|
|
578
608
|
timeout_ms = get_policy_value(policy, 'secrets', 'timeout_ms', default=30000)
|
|
579
|
-
timeout_seconds = timeout_ms / 1000.0
|
|
580
609
|
|
|
581
610
|
document = Document(path=os.path.basename(file_path), content=content, is_git_diff_format=False)
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
611
|
+
return _scan_documents_for_secrets(
|
|
612
|
+
ctx, [document], timeout_ms, payload, AiHookEventType.FILE_READ, paths=(file_path,)
|
|
613
|
+
)
|
|
@@ -7,6 +7,10 @@ respective IDE class.
|
|
|
7
7
|
|
|
8
8
|
import uuid
|
|
9
9
|
from dataclasses import dataclass, field
|
|
10
|
+
from typing import TYPE_CHECKING
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from cycode.cli.apps.ai_guardrails.scan.prompt_images import PromptImage
|
|
10
14
|
|
|
11
15
|
|
|
12
16
|
@dataclass
|
|
@@ -33,6 +37,9 @@ class AIHookPayload:
|
|
|
33
37
|
|
|
34
38
|
# Event-specific data
|
|
35
39
|
prompt: str | None = None # PROMPT events
|
|
40
|
+
# Images attached to the prompt, scanned with its text. Filled by scan_command (IDE.collect_prompt_images),
|
|
41
|
+
# not at parse time: collecting moves per-session state forward, so only the process that scans may do it.
|
|
42
|
+
images: list['PromptImage'] = field(default_factory=list)
|
|
36
43
|
file_path: str | None = None # FILE_READ events
|
|
37
44
|
mcp_server_name: str | None = None # MCP_EXECUTION events
|
|
38
45
|
mcp_tool_name: str | None = None
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"""Images attached to an AI prompt, scanned for secrets along with its text.
|
|
2
|
+
|
|
3
|
+
Some IDEs (GitHub Copilot) save a prompt's attachments to disk before its hook runs, yet never name them in the
|
|
4
|
+
hook payload. The IDE integration finds the candidates (``IDE.collect_prompt_images``); this module holds what is
|
|
5
|
+
IDE-agnostic about them: the filters every candidate passes, and the per-session prompt marks that turn "files saved
|
|
6
|
+
for this prompt" into "files saved since the session's previous prompt".
|
|
7
|
+
|
|
8
|
+
A session's first prompt looks back a fixed time rather than to session start: VS Code fires SessionStart together
|
|
9
|
+
with the first prompt, after its attachments were already saved.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import hashlib
|
|
13
|
+
import json
|
|
14
|
+
import os
|
|
15
|
+
import stat
|
|
16
|
+
from collections.abc import Iterable
|
|
17
|
+
from dataclasses import dataclass
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
from cycode.cli.consts import CYCODE_CONFIGURATION_DIRECTORY, FILE_MAX_SIZE_LIMIT_IN_BYTES
|
|
21
|
+
from cycode.cli.utils.path_utils import atomic_write_text, quarantine_corrupt_file
|
|
22
|
+
from cycode.logger import get_logger
|
|
23
|
+
|
|
24
|
+
logger = get_logger('AI Guardrails')
|
|
25
|
+
|
|
26
|
+
PROMPT_MARKS_FILE_NAME = 'ai-guardrails-prompt-marks.json'
|
|
27
|
+
|
|
28
|
+
# Each image adds to the scan's time, which the IDE's hook timeout bounds
|
|
29
|
+
MAX_PROMPT_IMAGES = 5
|
|
30
|
+
|
|
31
|
+
# Covers attachments saved a while before the prompt was sent
|
|
32
|
+
FIRST_PROMPT_LOOKBACK_SECONDS = 600
|
|
33
|
+
|
|
34
|
+
# A session idle this long loses its mark; if it comes back, its next prompt falls back to the lookback
|
|
35
|
+
_MARK_RETENTION_SECONDS = 7 * 24 * 60 * 60
|
|
36
|
+
|
|
37
|
+
# The image formats sent for scanning, by signature (a file's own extension can be wrong or missing), with the
|
|
38
|
+
# extensions that name each one
|
|
39
|
+
_IMAGE_FORMATS = (
|
|
40
|
+
(b'\x89PNG\r\n\x1a\n', ('.png',)),
|
|
41
|
+
(b'\xff\xd8\xff', ('.jpg', '.jpeg')),
|
|
42
|
+
)
|
|
43
|
+
_SIGNATURE_LENGTH = max(len(signature) for signature, _ in _IMAGE_FORMATS)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def get_prompt_marks_path() -> Path:
|
|
47
|
+
return Path.home() / CYCODE_CONFIGURATION_DIRECTORY / PROMPT_MARKS_FILE_NAME
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _load_marks() -> dict[str, float]:
|
|
51
|
+
"""``{session_id: timestamp}``; empty when the file is absent, or corrupt (then it is moved aside)."""
|
|
52
|
+
path = get_prompt_marks_path()
|
|
53
|
+
if not path.exists():
|
|
54
|
+
return {}
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
with open(path, encoding='UTF-8') as file:
|
|
58
|
+
marks = json.load(file)
|
|
59
|
+
if not isinstance(marks, dict):
|
|
60
|
+
raise TypeError('prompt marks are not an object')
|
|
61
|
+
return {str(session_id): float(timestamp) for session_id, timestamp in marks.items()}
|
|
62
|
+
except Exception as e:
|
|
63
|
+
logger.warning('Prompt marks file is corrupt and will be moved aside', exc_info=e)
|
|
64
|
+
quarantine_corrupt_file(str(path))
|
|
65
|
+
return {}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def get_prompt_mark(session_id: str | None, now: float) -> float:
|
|
69
|
+
"""Where a prompt's attachments start: the session's previous prompt, or the first-prompt lookback."""
|
|
70
|
+
mark = _load_marks().get(session_id) if session_id else None
|
|
71
|
+
if mark is None:
|
|
72
|
+
return now - FIRST_PROMPT_LOOKBACK_SECONDS
|
|
73
|
+
# A mark from before the clock was set back must not hide every new file
|
|
74
|
+
return min(mark, now)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def save_prompt_mark(session_id: str | None, now: float) -> None:
|
|
78
|
+
"""Move the session's mark to ``now`` and drop the marks of long-idle sessions. Never raises.
|
|
79
|
+
|
|
80
|
+
Unlocked read-modify-write: two sessions prompting at the same moment may lose one update, which only sends that
|
|
81
|
+
session's next prompt back to the lookback. The atomic write keeps the file whole.
|
|
82
|
+
"""
|
|
83
|
+
if not session_id:
|
|
84
|
+
return
|
|
85
|
+
|
|
86
|
+
marks = _load_marks()
|
|
87
|
+
marks[session_id] = now
|
|
88
|
+
cutoff = now - _MARK_RETENTION_SECONDS
|
|
89
|
+
marks = {key: timestamp for key, timestamp in marks.items() if timestamp >= cutoff}
|
|
90
|
+
|
|
91
|
+
path = get_prompt_marks_path()
|
|
92
|
+
try:
|
|
93
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
94
|
+
atomic_write_text(str(path), json.dumps(marks))
|
|
95
|
+
except Exception as e:
|
|
96
|
+
logger.debug('Failed to save prompt marks', exc_info=e)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def modified_between(paths: Iterable[Path], since: float, until: float) -> list[Path]:
|
|
100
|
+
"""The paths last modified in ``[since, until)``, oldest first (the order they were attached in).
|
|
101
|
+
|
|
102
|
+
Half-open so that each file belongs to exactly one prompt: a file saved while this prompt's images are being
|
|
103
|
+
collected is left to the next prompt, whose window starts where this one ends.
|
|
104
|
+
"""
|
|
105
|
+
dated = []
|
|
106
|
+
for path in paths:
|
|
107
|
+
try:
|
|
108
|
+
modified_at = path.stat().st_mtime
|
|
109
|
+
except OSError:
|
|
110
|
+
continue
|
|
111
|
+
if since <= modified_at < until:
|
|
112
|
+
dated.append((modified_at, path))
|
|
113
|
+
return [path for _, path in sorted(dated, key=lambda item: item[0])]
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _image_extensions(content: bytes) -> tuple[str, ...]:
|
|
117
|
+
return next((extensions for signature, extensions in _IMAGE_FORMATS if content.startswith(signature)), ())
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def read_prompt_image(path: str | os.PathLike) -> bytes | None:
|
|
121
|
+
"""The bytes of a scannable image - a regular PNG or JPEG file within the size limit - or None.
|
|
122
|
+
|
|
123
|
+
Regular files only, checked before opening: an `@` mention can name a FIFO or a device, and reading one would
|
|
124
|
+
hang the hook. The signature is read first, so a mentioned source file is never read in full.
|
|
125
|
+
"""
|
|
126
|
+
try:
|
|
127
|
+
file_stat = os.stat(path)
|
|
128
|
+
if not stat.S_ISREG(file_stat.st_mode) or file_stat.st_size > FILE_MAX_SIZE_LIMIT_IN_BYTES:
|
|
129
|
+
return None
|
|
130
|
+
with open(path, 'rb') as file:
|
|
131
|
+
head = file.read(_SIGNATURE_LENGTH)
|
|
132
|
+
if not _image_extensions(head):
|
|
133
|
+
return None
|
|
134
|
+
# One byte past the limit tells a file that grew since the stat
|
|
135
|
+
content = head + file.read(FILE_MAX_SIZE_LIMIT_IN_BYTES + 1 - len(head))
|
|
136
|
+
except (OSError, ValueError) as e:
|
|
137
|
+
logger.debug('Failed to read a prompt image candidate, %s', {'path': str(path)}, exc_info=e)
|
|
138
|
+
return None
|
|
139
|
+
|
|
140
|
+
return content if len(content) <= FILE_MAX_SIZE_LIMIT_IN_BYTES else None
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@dataclass(frozen=True)
|
|
144
|
+
class PromptImage:
|
|
145
|
+
"""An image attached to a prompt, read once when it is collected: where it was, and its bytes."""
|
|
146
|
+
|
|
147
|
+
path: str
|
|
148
|
+
content: bytes
|
|
149
|
+
|
|
150
|
+
@property
|
|
151
|
+
def file_name(self) -> str:
|
|
152
|
+
"""The file's name, plus the extension of its actual format when its own extension doesn't name it."""
|
|
153
|
+
name = os.path.basename(self.path)
|
|
154
|
+
extensions = _image_extensions(self.content)
|
|
155
|
+
if extensions and os.path.splitext(name)[1].lower() not in extensions:
|
|
156
|
+
name += extensions[0]
|
|
157
|
+
return name
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def select_prompt_images(candidates: Iterable[str | os.PathLike]) -> list[PromptImage]:
|
|
161
|
+
"""The candidates to scan, in order: scannable images (see read_prompt_image), each content once, at most
|
|
162
|
+
MAX_PROMPT_IMAGES.
|
|
163
|
+
|
|
164
|
+
Once per content because the same image can be attached twice, for example pasted and also mentioned by path.
|
|
165
|
+
"""
|
|
166
|
+
selected: list[PromptImage] = []
|
|
167
|
+
seen_digests: set[str] = set()
|
|
168
|
+
for candidate in candidates:
|
|
169
|
+
content = read_prompt_image(candidate)
|
|
170
|
+
if content is None:
|
|
171
|
+
continue
|
|
172
|
+
|
|
173
|
+
digest = hashlib.sha256(content).hexdigest()
|
|
174
|
+
if digest in seen_digests:
|
|
175
|
+
continue
|
|
176
|
+
|
|
177
|
+
if len(selected) == MAX_PROMPT_IMAGES:
|
|
178
|
+
logger.debug('More images than a prompt scans; skipping the rest, %s', {'max_images': MAX_PROMPT_IMAGES})
|
|
179
|
+
break
|
|
180
|
+
|
|
181
|
+
seen_digests.add(digest)
|
|
182
|
+
selected.append(PromptImage(path=str(candidate), content=content))
|
|
183
|
+
|
|
184
|
+
return selected
|
{cycode-3.27.1.dev11 → cycode-3.27.2.dev1}/cycode/cli/apps/ai_guardrails/scan/scan_command.py
RENAMED
|
@@ -87,6 +87,15 @@ def _should_skip_payload(ide_integration: IDE, payload: dict | None) -> bool:
|
|
|
87
87
|
return False
|
|
88
88
|
|
|
89
89
|
|
|
90
|
+
def _collect_prompt_images(ide_integration: IDE, payload: dict) -> list[str]:
|
|
91
|
+
"""Best-effort: an image that can't be collected goes unscanned, but the prompt text is still scanned."""
|
|
92
|
+
try:
|
|
93
|
+
return ide_integration.collect_prompt_images(payload)
|
|
94
|
+
except Exception as e:
|
|
95
|
+
logger.debug('Failed to collect prompt images, scanning the text only', exc_info=e)
|
|
96
|
+
return []
|
|
97
|
+
|
|
98
|
+
|
|
90
99
|
def _initialize_clients(ctx: typer.Context) -> None:
|
|
91
100
|
"""Initialize API clients.
|
|
92
101
|
|
|
@@ -169,6 +178,12 @@ def scan_command(
|
|
|
169
178
|
try:
|
|
170
179
|
_initialize_clients(ctx)
|
|
171
180
|
|
|
181
|
+
if event_name == AiHookEventType.PROMPT:
|
|
182
|
+
# Always sent: the server decides whether to scan them.
|
|
183
|
+
# Here rather than in parse_hook_payload: collecting moves the session's prompt mark forward, so it
|
|
184
|
+
# runs once, after the detach decision - a parent that detached would leave its child nothing to find.
|
|
185
|
+
unified_payload.images = _collect_prompt_images(ide_integration, payload)
|
|
186
|
+
|
|
172
187
|
decision = handler(ctx, unified_payload, policy)
|
|
173
188
|
logger.debug('Hook handler completed', extra={'event_name': event_name, 'action': decision.action.value})
|
|
174
189
|
output_json(ide_integration.build_hook_response(decision))
|