vibrante-node 2.5.1__py3-none-any.whl
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.
- src/core/__init__.py +0 -0
- src/core/engine.py +484 -0
- src/core/events.py +32 -0
- src/core/graph.py +74 -0
- src/core/integrity.py +925 -0
- src/core/loader.py +56 -0
- src/core/manifest.py +910 -0
- src/core/models.py +59 -0
- src/core/persistence.py +27 -0
- src/core/python_to_workflow.py +182 -0
- src/core/registry.py +314 -0
- src/core/workflow_to_python.py +801 -0
- src/main.py +188 -0
- src/models/__init__.py +0 -0
- src/nodes/__init__.py +0 -0
- src/nodes/ai/__init__.py +1 -0
- src/nodes/base.py +174 -0
- src/nodes/builtins/__init__.py +0 -0
- src/nodes/builtins/group_node.py +210 -0
- src/nodes/builtins/nodes.py +452 -0
- src/nodes/print.py +19 -0
- src/nodes/test.py +19 -0
- src/ui/__init__.py +0 -0
- src/ui/canvas/__init__.py +0 -0
- src/ui/canvas/backdrop.py +223 -0
- src/ui/canvas/canvas_search_bar.py +222 -0
- src/ui/canvas/edge.py +98 -0
- src/ui/canvas/mini_map.py +138 -0
- src/ui/canvas/node_search_popup.py +270 -0
- src/ui/canvas/scene.py +1149 -0
- src/ui/canvas/sticky_note.py +123 -0
- src/ui/canvas/view.py +285 -0
- src/ui/code_editor.py +435 -0
- src/ui/export_python_dialog.py +490 -0
- src/ui/gemini_api_dialog.py +41 -0
- src/ui/gemini_chat.py +370 -0
- src/ui/import_python_dialog.py +122 -0
- src/ui/library_panel.py +246 -0
- src/ui/log_panel.py +315 -0
- src/ui/node_builder.py +841 -0
- src/ui/node_widget.py +1009 -0
- src/ui/port_widget.py +116 -0
- src/ui/script_editor.py +53 -0
- src/ui/scripting_console.py +270 -0
- src/ui/settings_window.py +575 -0
- src/ui/window.py +2012 -0
- src/utils/color_manager.py +50 -0
- src/utils/config_manager.py +71 -0
- src/utils/env_manager.py +232 -0
- src/utils/highlighter.py +110 -0
- src/utils/paths.py +30 -0
- src/utils/prism_config.py +300 -0
- src/utils/prism_core.py +80 -0
- src/utils/qt_compat.py +159 -0
- src/utils/runtime.py +80 -0
- vibrante_node/CLA.md +96 -0
- vibrante_node/COMMERCIAL_LICENSE.md +170 -0
- vibrante_node/LICENSE +178 -0
- vibrante_node/LICENSES/AGPL-3.0.txt +661 -0
- vibrante_node/LICENSES/CC-BY-4.0-SCOPE.md +53 -0
- vibrante_node/LICENSES/CC-BY-4.0.txt +396 -0
- vibrante_node/LICENSES/GPL-3.0.txt +674 -0
- vibrante_node/LICENSES/LGPL-3.0.txt +165 -0
- vibrante_node/LICENSES/README.md +65 -0
- vibrante_node/THIRD_PARTY_NOTICES.txt +3277 -0
- vibrante_node/__init__.py +2 -0
- vibrante_node/app.py +60 -0
- vibrante_node/docs/AUTOMATION_API.html +785 -0
- vibrante_node/docs/DEVELOPER.html +891 -0
- vibrante_node/docs/DOCUMENTATION.html +2761 -0
- vibrante_node/docs/LICENSE.txt +35 -0
- vibrante_node/docs/NODE_BUILDER_API.html +1155 -0
- vibrante_node/docs/RELEASE_v1.0.5.html +140 -0
- vibrante_node/docs/RELEASE_v1.1.0.html +163 -0
- vibrante_node/docs/RELEASE_v1.1.5.html +286 -0
- vibrante_node/docs/RELEASE_v1.2.0.html +175 -0
- vibrante_node/docs/RELEASE_v1.3.0.html +168 -0
- vibrante_node/docs/RELEASE_v1.4.0.html +160 -0
- vibrante_node/docs/RELEASE_v1.5.0.html +432 -0
- vibrante_node/docs/RELEASE_v1.6.0.html +293 -0
- vibrante_node/docs/RELEASE_v1.6.1.html +171 -0
- vibrante_node/docs/RELEASE_v1.7.0.html +270 -0
- vibrante_node/docs/RELEASE_v1.8.0.html +201 -0
- vibrante_node/docs/RELEASE_v1.8.1.html +124 -0
- vibrante_node/docs/RELEASE_v1.8.2.html +119 -0
- vibrante_node/docs/RELEASE_v1.8.3.html +125 -0
- vibrante_node/docs/RELEASE_v1.8.4.html +210 -0
- vibrante_node/docs/RELEASE_v1.8.5.html +223 -0
- vibrante_node/docs/RELEASE_v2.0.0.html +284 -0
- vibrante_node/docs/RELEASE_v2.1.0.html +259 -0
- vibrante_node/docs/RELEASE_v2.1.1.html +156 -0
- vibrante_node/docs/RELEASE_v2.2.0.html +369 -0
- vibrante_node/docs/RELEASE_v2.2.1.html +168 -0
- vibrante_node/docs/RELEASE_v2.3.0.html +185 -0
- vibrante_node/docs/RELEASE_v2.4.0.html +446 -0
- vibrante_node/docs/RELEASE_v2.5.0.html +478 -0
- vibrante_node/docs/RELEASE_v2.5.1.html +190 -0
- vibrante_node/docs/USER_GUIDE.html +1407 -0
- vibrante_node/docs/index.html +103 -0
- vibrante_node/docs/portal/01_introduction.html +1177 -0
- vibrante_node/docs/portal/02_getting_started.html +1267 -0
- vibrante_node/docs/portal/03_user_guide.html +1736 -0
- vibrante_node/docs/portal/04_workflow_tutorials.html +1473 -0
- vibrante_node/docs/portal/05_node_development.html +1562 -0
- vibrante_node/docs/portal/06_backend_architecture.html +1373 -0
- vibrante_node/docs/portal/07_frontend_architecture.html +1588 -0
- vibrante_node/docs/portal/08_api_reference.html +2336 -0
- vibrante_node/docs/portal/09_advanced_topics.html +1664 -0
- vibrante_node/docs/portal/10_contribution_guide.html +1263 -0
- vibrante_node/docs/portal/11_troubleshooting.html +1108 -0
- vibrante_node/docs/portal/12_examples_library.html +1498 -0
- vibrante_node/docs/portal/13_general_purpose_automation.html +1472 -0
- vibrante_node/docs/portal/14_custom_nodes_api.html +1960 -0
- vibrante_node/docs/portal/index.html +605 -0
- vibrante_node/docs/portal/integrations_blender.html +605 -0
- vibrante_node/docs/portal/integrations_deadline.html +536 -0
- vibrante_node/docs/portal/integrations_houdini.html +787 -0
- vibrante_node/docs/portal/integrations_maya.html +675 -0
- vibrante_node/docs/portal/integrations_prism.html +628 -0
- vibrante_node/docs/portal/search.json +1 -0
- vibrante_node/docs/validation.json +333 -0
- vibrante_node/examples/arnold_lighting/orchestration_notes.md +45 -0
- vibrante_node/examples/arnold_lighting/prompt.md +47 -0
- vibrante_node/examples/automation/01_linear_chain.py +10 -0
- vibrante_node/examples/automation/02_batch_update_prefix.py +8 -0
- vibrante_node/examples/automation/03_reset_scene.py +5 -0
- vibrante_node/examples/automation/04_batch_execution.py +9 -0
- vibrante_node/examples/automation/05_git_backup.py +6 -0
- vibrante_node/examples/automation/06_reset_math_nodes.py +12 -0
- vibrante_node/examples/automation/07_stress_test_grid.py +8 -0
- vibrante_node/examples/automation/08_scene_summary.py +8 -0
- vibrante_node/examples/automation/09_toggle_bools.py +8 -0
- vibrante_node/examples/automation/10_session_report.py +7 -0
- vibrante_node/examples/automation/11_simple_math_node.py +7 -0
- vibrante_node/examples/cinematic_camera/orchestration_notes.md +56 -0
- vibrante_node/examples/cinematic_camera/prompt.md +50 -0
- vibrante_node/examples/cinematic_explosion/orchestration_notes.md +76 -0
- vibrante_node/examples/cinematic_explosion/prompt.md +47 -0
- vibrante_node/examples/cinematic_explosion/review.md +75 -0
- vibrante_node/examples/dust_wave/orchestration_notes.md +43 -0
- vibrante_node/examples/dust_wave/prompt.md +40 -0
- vibrante_node/examples/nodes/async_delay.py +21 -0
- vibrante_node/examples/nodes/connection_logger.py +25 -0
- vibrante_node/examples/nodes/data_filter.py +19 -0
- vibrante_node/examples/nodes/dict_merge.py +20 -0
- vibrante_node/examples/nodes/dict_summary.py +21 -0
- vibrante_node/examples/nodes/dropdown_selector.py +29 -0
- vibrante_node/examples/nodes/env_reader.py +18 -0
- vibrante_node/examples/nodes/list_item_picker.py +85 -0
- vibrante_node/examples/nodes/list_stats.py +27 -0
- vibrante_node/examples/nodes/logic_threshold.py +23 -0
- vibrante_node/examples/nodes/math_square.py +30 -0
- vibrante_node/examples/nodes/random_list.py +18 -0
- vibrante_node/examples/nodes/reactive_config.py +24 -0
- vibrante_node/examples/nodes/safety_reset.py +31 -0
- vibrante_node/examples/nodes/string_reverse.py +16 -0
- vibrante_node/icons/210429_DeadlineFreeOn10RenderMachines.jpg +0 -0
- vibrante_node/icons/README.md +39 -0
- vibrante_node/icons/blender_icon.png +0 -0
- vibrante_node/icons/braces.png +0 -0
- vibrante_node/icons/braces.svg +1 -0
- vibrante_node/icons/builder.png +0 -0
- vibrante_node/icons/check.png +0 -0
- vibrante_node/icons/check.svg +1 -0
- vibrante_node/icons/chevron-right.svg +3 -0
- vibrante_node/icons/code.png +0 -0
- vibrante_node/icons/code.svg +4 -0
- vibrante_node/icons/computer-window.png +0 -0
- vibrante_node/icons/data.png +0 -0
- vibrante_node/icons/data.svg +5 -0
- vibrante_node/icons/database-search.png +0 -0
- vibrante_node/icons/database-search.svg +5 -0
- vibrante_node/icons/database-zap.png +0 -0
- vibrante_node/icons/database-zap.svg +5 -0
- vibrante_node/icons/database.png +0 -0
- vibrante_node/icons/database.svg +5 -0
- vibrante_node/icons/dice.png +0 -0
- vibrante_node/icons/dice.svg +1 -0
- vibrante_node/icons/divide.svg +5 -0
- vibrante_node/icons/file-input.svg +6 -0
- vibrante_node/icons/file-plus.png +0 -0
- vibrante_node/icons/file-plus.svg +6 -0
- vibrante_node/icons/file-text.png +0 -0
- vibrante_node/icons/file-text.svg +7 -0
- vibrante_node/icons/folder-plus.png +0 -0
- vibrante_node/icons/folder-plus.svg +5 -0
- vibrante_node/icons/folder.png +0 -0
- vibrante_node/icons/folder.svg +3 -0
- vibrante_node/icons/gear.png +0 -0
- vibrante_node/icons/gear.svg +1 -0
- vibrante_node/icons/git-branch.svg +6 -0
- vibrante_node/icons/hash.png +0 -0
- vibrante_node/icons/hash.svg +1 -0
- vibrante_node/icons/houdini.svg +4 -0
- vibrante_node/icons/houdini_icon.png +0 -0
- vibrante_node/icons/http.png +0 -0
- vibrante_node/icons/list-check.png +0 -0
- vibrante_node/icons/list-check.svg +7 -0
- vibrante_node/icons/list-plus.svg +10 -0
- vibrante_node/icons/list.png +0 -0
- vibrante_node/icons/list.svg +8 -0
- vibrante_node/icons/logic.png +0 -0
- vibrante_node/icons/logic.svg +7 -0
- vibrante_node/icons/math.png +0 -0
- vibrante_node/icons/math.svg +4 -0
- vibrante_node/icons/maya_icon.jpg +0 -0
- vibrante_node/icons/message.png +0 -0
- vibrante_node/icons/message.svg +3 -0
- vibrante_node/icons/minus.svg +3 -0
- vibrante_node/icons/multiply.png +0 -0
- vibrante_node/icons/multiply.svg +1 -0
- vibrante_node/icons/online-library.png +0 -0
- vibrante_node/icons/percentage.svg +5 -0
- vibrante_node/icons/plus.png +0 -0
- vibrante_node/icons/plus.svg +1 -0
- vibrante_node/icons/print.png +0 -0
- vibrante_node/icons/print.svg +5 -0
- vibrante_node/icons/prism_icon.png +0 -0
- vibrante_node/icons/refresh.svg +6 -0
- vibrante_node/icons/repeat.svg +6 -0
- vibrante_node/icons/scales.png +0 -0
- vibrante_node/icons/scales.svg +1 -0
- vibrante_node/icons/shuffle.svg +7 -0
- vibrante_node/icons/string.png +0 -0
- vibrante_node/icons/string.svg +5 -0
- vibrante_node/icons/terminal.png +0 -0
- vibrante_node/icons/terminal.svg +1 -0
- vibrante_node/icons/timer.png +0 -0
- vibrante_node/icons/timer.svg +4 -0
- vibrante_node/icons/toggle-switch.svg +5 -0
- vibrante_node/icons/uppercase.png +0 -0
- vibrante_node/icons/uppercase.svg +1 -0
- vibrante_node/icons/variable-get.svg +4 -0
- vibrante_node/icons/variable-set.svg +6 -0
- vibrante_node/icons/variable.png +0 -0
- vibrante_node/icons/variable.svg +5 -0
- vibrante_node/icons/vibrante-node-icon.png +0 -0
- vibrante_node/icons/vibrante-node-logo.png +0 -0
- vibrante_node/icons/vibrante-node-main_logo.png +0 -0
- vibrante_node/icons/vibrante-node-resize_main_logo.png +0 -0
- vibrante_node/logo.png +0 -0
- vibrante_node/mcp_cli.py +36 -0
- vibrante_node/node_examples/Split_String.json +35 -0
- vibrante_node/node_examples/async_delay.json +32 -0
- vibrante_node/node_examples/delay_timer.json +29 -0
- vibrante_node/node_examples/file_reader.json +29 -0
- vibrante_node/node_examples/fruit_selector.json +37 -0
- vibrante_node/node_examples/json_parser.json +29 -0
- vibrante_node/node_examples/line_counter.json +29 -0
- vibrante_node/node_examples/list_append.json +32 -0
- vibrante_node/node_examples/list_images_recursive.json +55 -0
- vibrante_node/node_examples/logic_and.json +34 -0
- vibrante_node/node_examples/logic_compare.json +36 -0
- vibrante_node/node_examples/math_abs.json +29 -0
- vibrante_node/node_examples/math_add.json +32 -0
- vibrante_node/node_examples/reactive_config.json +28 -0
- vibrante_node/node_examples/string_uppercase.json +29 -0
- vibrante_node/nodes/Dropdown_Selector.json +27 -0
- vibrante_node/nodes/add_integers.json +34 -0
- vibrante_node/nodes/blender_action_bake_animation.json +23 -0
- vibrante_node/nodes/blender_action_custom.json +21 -0
- vibrante_node/nodes/blender_action_export_alembic.json +22 -0
- vibrante_node/nodes/blender_action_export_fbx.json +23 -0
- vibrante_node/nodes/blender_action_export_gltf.json +21 -0
- vibrante_node/nodes/blender_action_export_obj.json +19 -0
- vibrante_node/nodes/blender_action_export_usd.json +23 -0
- vibrante_node/nodes/blender_action_import_alembic.json +18 -0
- vibrante_node/nodes/blender_action_import_fbx.json +18 -0
- vibrante_node/nodes/blender_action_import_gltf.json +18 -0
- vibrante_node/nodes/blender_action_import_obj.json +18 -0
- vibrante_node/nodes/blender_action_new_blend.json +18 -0
- vibrante_node/nodes/blender_action_open_blend.json +18 -0
- vibrante_node/nodes/blender_action_render.json +23 -0
- vibrante_node/nodes/blender_action_save_blend.json +18 -0
- vibrante_node/nodes/blender_action_scene_info.json +17 -0
- vibrante_node/nodes/blender_action_set_frame_range.json +20 -0
- vibrante_node/nodes/blender_action_set_render_settings.json +27 -0
- vibrante_node/nodes/blender_get_action_result.json +22 -0
- vibrante_node/nodes/blender_headless.json +86 -0
- vibrante_node/nodes/compare.json +48 -0
- vibrante_node/nodes/console_print.json +29 -0
- vibrante_node/nodes/create_dictionary.json +18 -0
- vibrante_node/nodes/create_folder.json +17 -0
- vibrante_node/nodes/create_list.json +18 -0
- vibrante_node/nodes/deadline_blender_submit.json +38 -0
- vibrante_node/nodes/deadline_houdini_submit.json +38 -0
- vibrante_node/nodes/deadline_job_status.json +28 -0
- vibrante_node/nodes/deadline_maya_submit.json +40 -0
- vibrante_node/nodes/delay_timer.json +26 -0
- vibrante_node/nodes/example_random_float.json +35 -0
- vibrante_node/nodes/file_append.json +18 -0
- vibrante_node/nodes/file_write.json +18 -0
- vibrante_node/nodes/for_loop.json +46 -0
- vibrante_node/nodes/get_dict_value.json +19 -0
- vibrante_node/nodes/get_list_item.json +19 -0
- vibrante_node/nodes/houdini_action_bake_animation.json +20 -0
- vibrante_node/nodes/houdini_action_custom.json +20 -0
- vibrante_node/nodes/houdini_action_export_alembic.json +20 -0
- vibrante_node/nodes/houdini_action_export_camera_alembic.json +20 -0
- vibrante_node/nodes/houdini_action_export_fbx.json +18 -0
- vibrante_node/nodes/houdini_action_import_alembic.json +18 -0
- vibrante_node/nodes/houdini_action_import_camera.json +17 -0
- vibrante_node/nodes/houdini_action_import_fbx.json +18 -0
- vibrante_node/nodes/houdini_action_import_obj.json +18 -0
- vibrante_node/nodes/houdini_action_new_hip.json +16 -0
- vibrante_node/nodes/houdini_action_open_hip.json +17 -0
- vibrante_node/nodes/houdini_action_save_hip.json +17 -0
- vibrante_node/nodes/houdini_action_scene_info.json +16 -0
- vibrante_node/nodes/houdini_action_set_frame_range.json +18 -0
- vibrante_node/nodes/houdini_get_action_result.json +21 -0
- vibrante_node/nodes/houdini_headless.json +85 -0
- vibrante_node/nodes/houdini_scene_snapshot.json +41 -0
- vibrante_node/nodes/http_request.json +76 -0
- vibrante_node/nodes/if_condition.json +45 -0
- vibrante_node/nodes/list_directory.json +17 -0
- vibrante_node/nodes/list_images_recursive.json +41 -0
- vibrante_node/nodes/list_item_picker.json +41 -0
- vibrante_node/nodes/list_length.json +17 -0
- vibrante_node/nodes/logical_gate.json +45 -0
- vibrante_node/nodes/loop_body.json +62 -0
- vibrante_node/nodes/math_add.json +17 -0
- vibrante_node/nodes/math_divide.json +17 -0
- vibrante_node/nodes/math_modulo.json +17 -0
- vibrante_node/nodes/math_multiply.json +36 -0
- vibrante_node/nodes/math_subtract.json +17 -0
- vibrante_node/nodes/maya_action_assign_material.json +18 -0
- vibrante_node/nodes/maya_action_bake_animation.json +21 -0
- vibrante_node/nodes/maya_action_create_render_layer.json +19 -0
- vibrante_node/nodes/maya_action_custom.json +20 -0
- vibrante_node/nodes/maya_action_export_alembic.json +22 -0
- vibrante_node/nodes/maya_action_export_camera_alembic.json +20 -0
- vibrante_node/nodes/maya_action_export_fbx.json +18 -0
- vibrante_node/nodes/maya_action_import_alembic.json +17 -0
- vibrante_node/nodes/maya_action_import_camera.json +17 -0
- vibrante_node/nodes/maya_action_import_fbx.json +17 -0
- vibrante_node/nodes/maya_action_import_obj.json +17 -0
- vibrante_node/nodes/maya_action_list_references.json +16 -0
- vibrante_node/nodes/maya_action_new_scene.json +16 -0
- vibrante_node/nodes/maya_action_open_scene.json +18 -0
- vibrante_node/nodes/maya_action_playblast.json +22 -0
- vibrante_node/nodes/maya_action_reference_alembic.json +18 -0
- vibrante_node/nodes/maya_action_reference_scene.json +18 -0
- vibrante_node/nodes/maya_action_save_scene.json +18 -0
- vibrante_node/nodes/maya_action_scene_info.json +16 -0
- vibrante_node/nodes/maya_action_set_aovs.json +18 -0
- vibrante_node/nodes/maya_action_set_frame_range.json +18 -0
- vibrante_node/nodes/maya_action_set_render_settings.json +23 -0
- vibrante_node/nodes/maya_get_action_result.json +21 -0
- vibrante_node/nodes/maya_headless.json +27 -0
- vibrante_node/nodes/mcp_call_tool.json +19 -0
- vibrante_node/nodes/mcp_list_tools.json +18 -0
- vibrante_node/nodes/mcp_server_init.json +23 -0
- vibrante_node/nodes/message_node.json +32 -0
- vibrante_node/nodes/prism_add_integration.json +49 -0
- vibrante_node/nodes/prism_build_entity.json +45 -0
- vibrante_node/nodes/prism_change_project.json +37 -0
- vibrante_node/nodes/prism_core_info.json +37 -0
- vibrante_node/nodes/prism_core_init.json +46 -0
- vibrante_node/nodes/prism_create_category.json +44 -0
- vibrante_node/nodes/prism_create_entity.json +60 -0
- vibrante_node/nodes/prism_create_playblast.json +56 -0
- vibrante_node/nodes/prism_create_product_version.json +64 -0
- vibrante_node/nodes/prism_create_project.json +50 -0
- vibrante_node/nodes/prism_create_scene_from_preset.json +59 -0
- vibrante_node/nodes/prism_eval.json +42 -0
- vibrante_node/nodes/prism_get_aovs.json +29 -0
- vibrante_node/nodes/prism_get_asset_by_name.json +69 -0
- vibrante_node/nodes/prism_get_asset_type_by_name.json +62 -0
- vibrante_node/nodes/prism_get_asset_types_by_project.json +55 -0
- vibrante_node/nodes/prism_get_assets_by_project.json +41 -0
- vibrante_node/nodes/prism_get_assets_by_type.json +69 -0
- vibrante_node/nodes/prism_get_config.json +48 -0
- vibrante_node/nodes/prism_get_current_scene.json +37 -0
- vibrante_node/nodes/prism_get_departments.json +37 -0
- vibrante_node/nodes/prism_get_entity_info.json +69 -0
- vibrante_node/nodes/prism_get_entity_path.json +69 -0
- vibrante_node/nodes/prism_get_export_path.json +26 -0
- vibrante_node/nodes/prism_get_latest_product_path.json +34 -0
- vibrante_node/nodes/prism_get_media.json +29 -0
- vibrante_node/nodes/prism_get_media_versions.json +33 -0
- vibrante_node/nodes/prism_get_plugin.json +35 -0
- vibrante_node/nodes/prism_get_preset_scenes.json +35 -0
- vibrante_node/nodes/prism_get_product_versions.json +33 -0
- vibrante_node/nodes/prism_get_products.json +29 -0
- vibrante_node/nodes/prism_get_project_by_name.json +55 -0
- vibrante_node/nodes/prism_get_project_config_path.json +26 -0
- vibrante_node/nodes/prism_get_scene_files.json +45 -0
- vibrante_node/nodes/prism_get_scene_path.json +23 -0
- vibrante_node/nodes/prism_get_sequence_by_project.json +48 -0
- vibrante_node/nodes/prism_get_sequences_by_project.json +41 -0
- vibrante_node/nodes/prism_get_shot_by_name.json +62 -0
- vibrante_node/nodes/prism_get_shot_by_sequence.json +55 -0
- vibrante_node/nodes/prism_get_shot_info.json +69 -0
- vibrante_node/nodes/prism_get_shots.json +29 -0
- vibrante_node/nodes/prism_get_shots_by_project_sequence.json +48 -0
- vibrante_node/nodes/prism_get_shots_by_sequence.json +48 -0
- vibrante_node/nodes/prism_get_tasks.json +39 -0
- vibrante_node/nodes/prism_import_product.json +37 -0
- vibrante_node/nodes/prism_list_plugins.json +25 -0
- vibrante_node/nodes/prism_list_projects.json +25 -0
- vibrante_node/nodes/prism_login_token.json +33 -0
- vibrante_node/nodes/prism_monkey_patch.json +46 -0
- vibrante_node/nodes/prism_open_scene.json +33 -0
- vibrante_node/nodes/prism_popup.json +40 -0
- vibrante_node/nodes/prism_register_callback.json +58 -0
- vibrante_node/nodes/prism_save_scene_version.json +90 -0
- vibrante_node/nodes/prism_send_cmd.json +54 -0
- vibrante_node/nodes/prism_set_config.json +55 -0
- vibrante_node/nodes/prism_studio_assign_project.json +43 -0
- vibrante_node/nodes/prism_trigger_callback.json +42 -0
- vibrante_node/nodes/prism_usd_department_layer_path.json +35 -0
- vibrante_node/nodes/prism_usd_entity_path.json +29 -0
- vibrante_node/nodes/prism_usd_sublayer_path.json +41 -0
- vibrante_node/nodes/prism_usd_update_department_layer.json +33 -0
- vibrante_node/nodes/prism_usd_update_sublayer.json +33 -0
- vibrante_node/nodes/python_script.json +17 -0
- vibrante_node/nodes/scene_intent_extractor.json +25 -0
- vibrante_node/nodes/set_dict_value.json +20 -0
- vibrante_node/nodes/string_concat.json +47 -0
- vibrante_node/nodes/string_length.json +16 -0
- vibrante_node/nodes/string_lowercase.json +16 -0
- vibrante_node/nodes/string_replace.json +18 -0
- vibrante_node/nodes/string_split.json +17 -0
- vibrante_node/nodes/string_uppercase.json +16 -0
- vibrante_node/nodes/variable_node.json +42 -0
- vibrante_node/nodes/while_loop.json +18 -0
- vibrante_node/splash.png +0 -0
- vibrante_node/vfx_workflows/01_prism_project_overview.json +492 -0
- vibrante_node/vfx_workflows/02_maya_asset_publish.json +776 -0
- vibrante_node/vfx_workflows/03_multi_shot_alembic_export.json +856 -0
- vibrante_node/vfx_workflows/04_deadline_render_pipeline.json +994 -0
- vibrante_node/vfx_workflows/05_houdini_fx_pipeline.json +1056 -0
- vibrante_node/vfx_workflows/06_blender_multi_format_export.json +1206 -0
- vibrante_node/website_examples/database_query.json +69 -0
- vibrante_node/website_examples/email_notification.json +104 -0
- vibrante_node/website_examples/file_batch_processor.json +62 -0
- vibrante_node/website_examples/folder_monitor.json +55 -0
- vibrante_node/website_examples/hou_sop_chain.json +69 -0
- vibrante_node/website_examples/http_request.json +90 -0
- vibrante_node/website_examples/image_resizer.json +90 -0
- vibrante_node/website_examples/llm_text_generation.json +90 -0
- vibrante_node/website_examples/prism_multi_asset_publisher.json +76 -0
- vibrante_node/website_examples/regex_replace.json +69 -0
- vibrante_node/workflows/If_condition.json +134 -0
- vibrante_node/workflows/Maya_WorkFlow.json +464 -0
- vibrante_node/workflows/asset_intelligence_pipeline.json +259 -0
- vibrante_node/workflows/concat_string_with_loop.json +262 -0
- vibrante_node/workflows/delay_time.json +74 -0
- vibrante_node/workflows/example_workflow_maya_prism_demo.json +503 -0
- vibrante_node/workflows/example_workflow_prism_demo.json +276 -0
- vibrante_node/workflows/example_workflow_prism_demo_02.json +221 -0
- vibrante_node/workflows/extract_FPS_from_maya_scene.json +265 -0
- vibrante_node/workflows/for_each.json +260 -0
- vibrante_node/workflows/get_list_item.json +151 -0
- vibrante_node/workflows/hou_mcp_scene_context_demo.json +67 -0
- vibrante_node/workflows/list_recursive_images.json +103 -0
- vibrante_node/workflows/logic_if_example.json +262 -0
- vibrante_node/workflows/logic_if_with_variables.json +210 -0
- vibrante_node/workflows/loop_break_example.json +197 -0
- vibrante_node/workflows/loop_operation_example.json +382 -0
- vibrante_node/workflows/mcp_list_tools_demo.json +90 -0
- vibrante_node/workflows/prism_assets_workflow.json +131 -0
- vibrante_node/workflows/python_script_node.json +89 -0
- vibrante_node/workflows/run_in_sequence.json +158 -0
- vibrante_node/workflows/scene_intent_pipeline.json +134 -0
- vibrante_node/workflows/scene_planning_pipeline.json +258 -0
- vibrante_node/workflows/semantic_scene_intent.json +96 -0
- vibrante_node/workflows/setup_maya_scene.json +352 -0
- vibrante_node/workflows/tutorial_maya_headless_prism_pipeline.json +593 -0
- vibrante_node/workflows/two_way_switch.json +341 -0
- vibrante_node/workflows/while_loop_class_example.json +192 -0
- vibrante_node/workflows/while_loop_example.json +184 -0
- vibrante_node/workflows/while_loop_retry_example.json +276 -0
- vibrante_node-2.5.1.dist-info/METADATA +715 -0
- vibrante_node-2.5.1.dist-info/RECORD +487 -0
- vibrante_node-2.5.1.dist-info/WHEEL +5 -0
- vibrante_node-2.5.1.dist-info/entry_points.txt +3 -0
- vibrante_node-2.5.1.dist-info/licenses/CLA.md +96 -0
- vibrante_node-2.5.1.dist-info/licenses/COMMERCIAL_LICENSE.md +170 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSE +178 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSES/AGPL-3.0.txt +661 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSES/CC-BY-4.0-SCOPE.md +53 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSES/CC-BY-4.0.txt +396 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSES/GPL-3.0.txt +674 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSES/LGPL-3.0.txt +165 -0
- vibrante_node-2.5.1.dist-info/licenses/LICENSES/README.md +65 -0
- vibrante_node-2.5.1.dist-info/top_level.txt +2 -0
src/core/integrity.py
ADDED
|
@@ -0,0 +1,925 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Standalone file-integrity verification for Vibrante-Node (P7-B4.11 / S2).
|
|
3
|
+
|
|
4
|
+
STANDALONE MODULE
|
|
5
|
+
-----------------
|
|
6
|
+
This module is intentionally independent of ``src.core.registry`` and of node
|
|
7
|
+
execution. It performs SHA-256 file reads and computes *facts* (raw verification
|
|
8
|
+
results) plus an *explicit, undecided-aware* policy projection. It does **not**
|
|
9
|
+
wire itself into the loader, does not mutate the registry, does not execute node
|
|
10
|
+
code, and does not perform signature verification.
|
|
11
|
+
|
|
12
|
+
Import direction (reviewed, R5/R6): ``integrity`` may import ``manifest``;
|
|
13
|
+
``manifest`` must never import ``integrity``. Only ``manifest`` is imported here.
|
|
14
|
+
|
|
15
|
+
FACTS vs POLICY
|
|
16
|
+
---------------
|
|
17
|
+
- ``FileVerification.status`` (``VERIFY_*``) is an immutable *fact*. A mismatch is
|
|
18
|
+
never rewritten by policy.
|
|
19
|
+
- ``FilePolicy``/``ManifestOutcome``/``PolicyEvaluation``/``IntegrityReport``
|
|
20
|
+
(``POLICY_*``) are the *policy projection*. Policy is confined to
|
|
21
|
+
:func:`evaluate_manifest_outcome` and :func:`apply_source_class_policy`.
|
|
22
|
+
|
|
23
|
+
UNRESOLVED OWNER DECISIONS (NOT decided here)
|
|
24
|
+
---------------------------------------------
|
|
25
|
+
Every cell that an owner has not approved resolves to ``unresolved`` carrying the
|
|
26
|
+
exact question/decision identifier (``Q-S2-1``..``Q-S2-9``, ``U-1``..``U-11``,
|
|
27
|
+
``EXP-COLLISION``) or the documented non-numbered ``UNDECIDED`` marker. The
|
|
28
|
+
``warn_allow`` and ``allow`` policy values are **reserved** and are never emitted
|
|
29
|
+
until an owner decision resolves a cell.
|
|
30
|
+
|
|
31
|
+
Scope: ``coverage_scope = "json_only"`` (``.py`` / ``plugins/houdini/*`` coverage
|
|
32
|
+
is explicitly unresolved, Q-S2-7). A green report is therefore not whole-package
|
|
33
|
+
verification.
|
|
34
|
+
"""
|
|
35
|
+
from __future__ import annotations
|
|
36
|
+
|
|
37
|
+
import hashlib
|
|
38
|
+
import hmac
|
|
39
|
+
import os
|
|
40
|
+
import re
|
|
41
|
+
from dataclasses import dataclass
|
|
42
|
+
from typing import Mapping, Optional, Sequence, Tuple
|
|
43
|
+
|
|
44
|
+
from src.core import manifest
|
|
45
|
+
|
|
46
|
+
__all__ = [
|
|
47
|
+
"ALGORITHM",
|
|
48
|
+
"DEFAULT_CHUNK_SIZE",
|
|
49
|
+
"SUPPORTED_ALGORITHMS",
|
|
50
|
+
"COVERAGE_SCOPE",
|
|
51
|
+
# VERIFY_* (raw facts)
|
|
52
|
+
"VERIFY_VERIFIED",
|
|
53
|
+
"VERIFY_MISSING",
|
|
54
|
+
"VERIFY_UNREADABLE",
|
|
55
|
+
"VERIFY_MISMATCHED",
|
|
56
|
+
"VERIFY_MALFORMED",
|
|
57
|
+
"VERIFY_UNVERIFIED",
|
|
58
|
+
"VERIFY_ESCAPE",
|
|
59
|
+
"VERIFY_NOT_A_FILE",
|
|
60
|
+
"VERIFY_UNSTABLE",
|
|
61
|
+
"VERIFY_UNSUPPORTED",
|
|
62
|
+
"VERIFY_TOO_LARGE",
|
|
63
|
+
# POLICY_* (projection)
|
|
64
|
+
"POLICY_VERIFIED",
|
|
65
|
+
"POLICY_BLOCK",
|
|
66
|
+
"POLICY_UNRESOLVED",
|
|
67
|
+
"POLICY_WARN_ALLOW",
|
|
68
|
+
"POLICY_ALLOW",
|
|
69
|
+
"POLICY_PRECEDENCE",
|
|
70
|
+
# manifest outcome reasons
|
|
71
|
+
"MANIFEST_REASON_ABSENT",
|
|
72
|
+
"MANIFEST_REASON_MALFORMED",
|
|
73
|
+
"MANIFEST_REASON_UNSUPPORTED",
|
|
74
|
+
"MANIFEST_REASON_OVERSIZED",
|
|
75
|
+
"MANIFEST_REASON_UNREADABLE",
|
|
76
|
+
"MANIFEST_REASON_MISSING_INTEGRITY",
|
|
77
|
+
"MANIFEST_REASON_EMPTY_MAP",
|
|
78
|
+
"MANIFEST_REASON_COLLISION_UNUSABLE",
|
|
79
|
+
"MANIFEST_REASON_USABLE",
|
|
80
|
+
"MANIFEST_REASON_INCONSISTENT",
|
|
81
|
+
"MANIFEST_REASON_UNKNOWN_STATUS",
|
|
82
|
+
"MANIFEST_REASONS",
|
|
83
|
+
"MANIFEST_REASONS_POLICY",
|
|
84
|
+
"MANIFEST_REASONS_INVALID",
|
|
85
|
+
# unresolved identifiers
|
|
86
|
+
"Q_S2_1",
|
|
87
|
+
"Q_S2_2",
|
|
88
|
+
"Q_S2_3",
|
|
89
|
+
"Q_S2_4",
|
|
90
|
+
"Q_S2_5",
|
|
91
|
+
"Q_S2_6",
|
|
92
|
+
"Q_S2_7",
|
|
93
|
+
"Q_S2_8",
|
|
94
|
+
"Q_S2_9",
|
|
95
|
+
"U1",
|
|
96
|
+
"UNDECIDED_CODE",
|
|
97
|
+
# errors
|
|
98
|
+
"ManifestContractError",
|
|
99
|
+
# dataclasses
|
|
100
|
+
"FileFingerprint",
|
|
101
|
+
"FileHashResult",
|
|
102
|
+
"FileVerification",
|
|
103
|
+
"FilePolicy",
|
|
104
|
+
"ManifestFacts",
|
|
105
|
+
"ManifestOutcome",
|
|
106
|
+
"PolicyEvaluation",
|
|
107
|
+
"IntegrityIssue",
|
|
108
|
+
"IntegrityReport",
|
|
109
|
+
# functions
|
|
110
|
+
"hash_file",
|
|
111
|
+
"hash_fileobj",
|
|
112
|
+
"fingerprint_file",
|
|
113
|
+
"verify_file",
|
|
114
|
+
"verify_files",
|
|
115
|
+
"collect_undeclared",
|
|
116
|
+
"undeclared_verifications",
|
|
117
|
+
"classify_manifest_facts",
|
|
118
|
+
"evaluate_manifest_outcome",
|
|
119
|
+
"apply_source_class_policy",
|
|
120
|
+
"verify_integrity",
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
# ---------------------------------------------------------------------------
|
|
124
|
+
# Constants
|
|
125
|
+
# ---------------------------------------------------------------------------
|
|
126
|
+
|
|
127
|
+
ALGORITHM: str = manifest.ALGORITHM # "sha256" (single source of truth)
|
|
128
|
+
DEFAULT_CHUNK_SIZE: int = 65536 # bounded-memory streaming read size
|
|
129
|
+
SUPPORTED_ALGORITHMS: frozenset = frozenset({ALGORITHM})
|
|
130
|
+
COVERAGE_SCOPE: str = "json_only"
|
|
131
|
+
|
|
132
|
+
# Raw verification facts (audit trail; never rewritten by policy).
|
|
133
|
+
VERIFY_VERIFIED: str = "verified"
|
|
134
|
+
VERIFY_MISSING: str = "missing"
|
|
135
|
+
VERIFY_UNREADABLE: str = "unreadable"
|
|
136
|
+
VERIFY_MISMATCHED: str = "mismatched"
|
|
137
|
+
VERIFY_MALFORMED: str = "malformed"
|
|
138
|
+
VERIFY_UNVERIFIED: str = "unverified"
|
|
139
|
+
VERIFY_ESCAPE: str = "escape"
|
|
140
|
+
VERIFY_NOT_A_FILE: str = "not_a_file"
|
|
141
|
+
VERIFY_UNSTABLE: str = "unstable"
|
|
142
|
+
VERIFY_UNSUPPORTED: str = "unsupported"
|
|
143
|
+
VERIFY_TOO_LARGE: str = "too_large"
|
|
144
|
+
|
|
145
|
+
# Policy projection values. ``warn_allow``/``allow`` are reserved: no code path
|
|
146
|
+
# emits them until an owner decision resolves a policy cell.
|
|
147
|
+
POLICY_VERIFIED: str = "verified"
|
|
148
|
+
POLICY_BLOCK: str = "block"
|
|
149
|
+
POLICY_UNRESOLVED: str = "unresolved"
|
|
150
|
+
POLICY_WARN_ALLOW: str = "warn_allow"
|
|
151
|
+
POLICY_ALLOW: str = "allow"
|
|
152
|
+
|
|
153
|
+
# Strictest first.
|
|
154
|
+
POLICY_PRECEDENCE: Tuple[str, ...] = (
|
|
155
|
+
POLICY_BLOCK,
|
|
156
|
+
POLICY_UNRESOLVED,
|
|
157
|
+
POLICY_WARN_ALLOW,
|
|
158
|
+
POLICY_ALLOW,
|
|
159
|
+
POLICY_VERIFIED,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
# Manifest-outcome reasons (stable discriminators).
|
|
163
|
+
MANIFEST_REASON_ABSENT: str = "absent"
|
|
164
|
+
MANIFEST_REASON_MALFORMED: str = "malformed"
|
|
165
|
+
MANIFEST_REASON_UNSUPPORTED: str = "unsupported"
|
|
166
|
+
MANIFEST_REASON_OVERSIZED: str = "oversized"
|
|
167
|
+
MANIFEST_REASON_UNREADABLE: str = "unreadable"
|
|
168
|
+
MANIFEST_REASON_MISSING_INTEGRITY: str = "missing_integrity_section"
|
|
169
|
+
MANIFEST_REASON_EMPTY_MAP: str = "empty_map"
|
|
170
|
+
MANIFEST_REASON_COLLISION_UNUSABLE: str = "collision_unusable"
|
|
171
|
+
MANIFEST_REASON_USABLE: str = "usable_manifest"
|
|
172
|
+
MANIFEST_REASON_INCONSISTENT: str = "inconsistent"
|
|
173
|
+
MANIFEST_REASON_UNKNOWN_STATUS: str = "unknown_status"
|
|
174
|
+
|
|
175
|
+
MANIFEST_REASONS: frozenset = frozenset(
|
|
176
|
+
{
|
|
177
|
+
MANIFEST_REASON_ABSENT,
|
|
178
|
+
MANIFEST_REASON_MALFORMED,
|
|
179
|
+
MANIFEST_REASON_UNSUPPORTED,
|
|
180
|
+
MANIFEST_REASON_OVERSIZED,
|
|
181
|
+
MANIFEST_REASON_UNREADABLE,
|
|
182
|
+
MANIFEST_REASON_MISSING_INTEGRITY,
|
|
183
|
+
MANIFEST_REASON_EMPTY_MAP,
|
|
184
|
+
MANIFEST_REASON_COLLISION_UNUSABLE,
|
|
185
|
+
MANIFEST_REASON_USABLE,
|
|
186
|
+
MANIFEST_REASON_INCONSISTENT,
|
|
187
|
+
MANIFEST_REASON_UNKNOWN_STATUS,
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
MANIFEST_REASONS_POLICY: frozenset = MANIFEST_REASONS - {
|
|
191
|
+
MANIFEST_REASON_INCONSISTENT,
|
|
192
|
+
MANIFEST_REASON_UNKNOWN_STATUS,
|
|
193
|
+
}
|
|
194
|
+
MANIFEST_REASONS_INVALID: frozenset = frozenset(
|
|
195
|
+
{MANIFEST_REASON_INCONSISTENT, MANIFEST_REASON_UNKNOWN_STATUS}
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
_EXPECTED_STATUSES: frozenset = frozenset(
|
|
199
|
+
{
|
|
200
|
+
manifest.STATUS_OK,
|
|
201
|
+
manifest.STATUS_ABSENT,
|
|
202
|
+
manifest.STATUS_MALFORMED,
|
|
203
|
+
manifest.STATUS_UNSUPPORTED,
|
|
204
|
+
manifest.STATUS_OVERSIZED,
|
|
205
|
+
manifest.STATUS_UNREADABLE,
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
_COLLISION_ISSUE_CODES: frozenset = frozenset(
|
|
210
|
+
{"case_collision", "expansion_key_collision"}
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
# Unresolved owner questions (preserved verbatim; never decided here).
|
|
214
|
+
Q_S2_1: str = "Q-S2-1"
|
|
215
|
+
Q_S2_2: str = "Q-S2-2"
|
|
216
|
+
Q_S2_3: str = "Q-S2-3"
|
|
217
|
+
Q_S2_4: str = "Q-S2-4"
|
|
218
|
+
Q_S2_5: str = "Q-S2-5"
|
|
219
|
+
Q_S2_6: str = "Q-S2-6"
|
|
220
|
+
Q_S2_7: str = "Q-S2-7"
|
|
221
|
+
Q_S2_8: str = "Q-S2-8"
|
|
222
|
+
Q_S2_9: str = "Q-S2-9"
|
|
223
|
+
|
|
224
|
+
# U-1 is the only numbered owner decision referenced by this module (malformed
|
|
225
|
+
# manifests for non-external directories). It is sourced from the manifest
|
|
226
|
+
# module's ``UNRESOLVED_DECISIONS`` so the two modules cannot drift.
|
|
227
|
+
U1: str = "U-1"
|
|
228
|
+
assert U1 in manifest.UNRESOLVED_DECISIONS # pragma: no cover - contract guard
|
|
229
|
+
|
|
230
|
+
# Documented, non-numbered marker for defensive file states that no owner
|
|
231
|
+
# question covers. Mirrors the manifest module's ``EXP-COLLISION`` precedent:
|
|
232
|
+
# it records an undecided cell rather than inventing policy.
|
|
233
|
+
UNDECIDED_CODE: str = "UNDECIDED"
|
|
234
|
+
|
|
235
|
+
_HASH_RE = re.compile(r"^[0-9a-f]{64}$")
|
|
236
|
+
|
|
237
|
+
# Module-level open seam so tests can exercise the unreadable path deterministically.
|
|
238
|
+
_OPEN = open
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# ---------------------------------------------------------------------------
|
|
242
|
+
# Errors
|
|
243
|
+
# ---------------------------------------------------------------------------
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class ManifestContractError(Exception):
|
|
247
|
+
"""An S1 result violates its documented contract (a defect, not a state).
|
|
248
|
+
|
|
249
|
+
Raised only for the non-policy manifest reasons ``inconsistent`` and
|
|
250
|
+
``unknown_status``. It is **not** an ``OSError``, so it propagates per the
|
|
251
|
+
error taxonomy instead of becoming a verification result; the policy layer
|
|
252
|
+
never invents a decision for such input.
|
|
253
|
+
"""
|
|
254
|
+
|
|
255
|
+
def __init__(self, reason: str, detail: str = "") -> None:
|
|
256
|
+
super().__init__(f"{reason}: {detail}" if detail else reason)
|
|
257
|
+
self.reason = reason
|
|
258
|
+
self.detail = detail
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
# ---------------------------------------------------------------------------
|
|
262
|
+
# Dataclasses
|
|
263
|
+
# ---------------------------------------------------------------------------
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
@dataclass(frozen=True)
|
|
267
|
+
class FileFingerprint:
|
|
268
|
+
"""Change-detection *heuristic* only -- not cryptographic proof of identity."""
|
|
269
|
+
|
|
270
|
+
path: str
|
|
271
|
+
algorithm: str
|
|
272
|
+
size: Optional[int]
|
|
273
|
+
digest: Optional[str]
|
|
274
|
+
mtime_ns: Optional[int]
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
@dataclass(frozen=True)
|
|
278
|
+
class FileHashResult:
|
|
279
|
+
"""Raw outcome of hashing a byte stream (no expected value involved)."""
|
|
280
|
+
|
|
281
|
+
path: Optional[str]
|
|
282
|
+
algorithm: str
|
|
283
|
+
digest: Optional[str]
|
|
284
|
+
size: Optional[int]
|
|
285
|
+
error: Optional[str] = None
|
|
286
|
+
too_large: bool = False
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
@dataclass(frozen=True)
|
|
290
|
+
class FileVerification:
|
|
291
|
+
"""Immutable raw verification *fact* for one declared/undeclared file."""
|
|
292
|
+
|
|
293
|
+
path: str
|
|
294
|
+
status: str # VERIFY_*
|
|
295
|
+
expected: Optional[str]
|
|
296
|
+
actual: Optional[str]
|
|
297
|
+
size: Optional[int]
|
|
298
|
+
algorithm: str
|
|
299
|
+
detail: Optional[str] = None
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
@dataclass(frozen=True)
|
|
303
|
+
class FilePolicy:
|
|
304
|
+
"""Policy projection for one file (``POLICY_*`` + unresolved identifier)."""
|
|
305
|
+
|
|
306
|
+
path: str
|
|
307
|
+
policy: str
|
|
308
|
+
unresolved: Optional[str]
|
|
309
|
+
reason: str
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
@dataclass(frozen=True)
|
|
313
|
+
class ManifestFacts:
|
|
314
|
+
"""Classified manifest facts (status + usability + stable reason)."""
|
|
315
|
+
|
|
316
|
+
status: str
|
|
317
|
+
usable: bool
|
|
318
|
+
reason: str
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
@dataclass(frozen=True)
|
|
322
|
+
class ManifestOutcome:
|
|
323
|
+
"""Manifest-level policy projection."""
|
|
324
|
+
|
|
325
|
+
policy: str
|
|
326
|
+
reason: str
|
|
327
|
+
status: str
|
|
328
|
+
usable: bool
|
|
329
|
+
unresolved: Optional[str] = None
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
@dataclass(frozen=True)
|
|
333
|
+
class PolicyEvaluation:
|
|
334
|
+
"""Aggregate of the manifest outcome and every file policy."""
|
|
335
|
+
|
|
336
|
+
policy: str
|
|
337
|
+
blocked: bool
|
|
338
|
+
has_unresolved: bool
|
|
339
|
+
unresolved_codes: Tuple[str, ...]
|
|
340
|
+
manifest_outcome: ManifestOutcome
|
|
341
|
+
files: Tuple[FilePolicy, ...]
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
@dataclass(frozen=True)
|
|
345
|
+
class IntegrityIssue:
|
|
346
|
+
"""A single structured observation about a verification run."""
|
|
347
|
+
|
|
348
|
+
code: str
|
|
349
|
+
message: str
|
|
350
|
+
unresolved: Optional[str] = None
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
@dataclass(frozen=True)
|
|
354
|
+
class IntegrityReport:
|
|
355
|
+
"""Deterministic, immutable result of :func:`verify_integrity`."""
|
|
356
|
+
|
|
357
|
+
directory: str
|
|
358
|
+
source_class: str
|
|
359
|
+
manifest_status: str
|
|
360
|
+
manifest_usable: bool
|
|
361
|
+
coverage_scope: str
|
|
362
|
+
policy: str
|
|
363
|
+
blocked: bool
|
|
364
|
+
has_unresolved: bool
|
|
365
|
+
unresolved_codes: Tuple[str, ...]
|
|
366
|
+
manifest_outcome: ManifestOutcome
|
|
367
|
+
files: Tuple[FileVerification, ...]
|
|
368
|
+
policies: Tuple[FilePolicy, ...]
|
|
369
|
+
undeclared: Tuple[str, ...]
|
|
370
|
+
issues: Tuple[IntegrityIssue, ...]
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
def _to_integrity_issue(issue) -> IntegrityIssue:
|
|
374
|
+
"""Normalize an issue to the single public ``IntegrityIssue`` contract.
|
|
375
|
+
|
|
376
|
+
S1 ``manifest.ManifestIssue`` and S2 ``IntegrityIssue`` carry exactly the same
|
|
377
|
+
three fields (``code``, ``message``, ``unresolved``) and nothing else, so
|
|
378
|
+
normalization preserves every field and intentionally omits no information.
|
|
379
|
+
Consequently ``IntegrityReport.issues`` is always a tuple of ``IntegrityIssue``
|
|
380
|
+
objects, regardless of whether an issue originated in S1 or S2.
|
|
381
|
+
"""
|
|
382
|
+
if isinstance(issue, IntegrityIssue):
|
|
383
|
+
return issue
|
|
384
|
+
return IntegrityIssue(
|
|
385
|
+
code=getattr(issue, "code", "issue"),
|
|
386
|
+
message=getattr(issue, "message", ""),
|
|
387
|
+
unresolved=getattr(issue, "unresolved", None),
|
|
388
|
+
)
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
@dataclass(frozen=True)
|
|
392
|
+
class _StatSig:
|
|
393
|
+
size: int
|
|
394
|
+
mtime_ns: int
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
# ---------------------------------------------------------------------------
|
|
398
|
+
# Hashing primitives (bounded memory)
|
|
399
|
+
# ---------------------------------------------------------------------------
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
def _require_algorithm(algorithm: str) -> None:
|
|
403
|
+
if not isinstance(algorithm, str) or algorithm.strip().lower() not in SUPPORTED_ALGORITHMS:
|
|
404
|
+
raise ValueError(f"unsupported algorithm {algorithm!r}; supported: {sorted(SUPPORTED_ALGORITHMS)}")
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
def _require_chunk_size(chunk_size: int) -> None:
|
|
408
|
+
if isinstance(chunk_size, bool) or not isinstance(chunk_size, int) or chunk_size <= 0:
|
|
409
|
+
raise ValueError(f"chunk_size must be a positive int, got {chunk_size!r}")
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
def hash_fileobj(
|
|
413
|
+
fileobj,
|
|
414
|
+
*,
|
|
415
|
+
algorithm: str = ALGORITHM,
|
|
416
|
+
chunk_size: int = DEFAULT_CHUNK_SIZE,
|
|
417
|
+
max_bytes: Optional[int] = None,
|
|
418
|
+
) -> FileHashResult:
|
|
419
|
+
"""Hash a binary file object with fixed-size reads.
|
|
420
|
+
|
|
421
|
+
Every read uses exactly ``chunk_size`` bytes (never ``read()`` / ``read(-1)``),
|
|
422
|
+
so peak memory is bounded by ``chunk_size`` regardless of file size. Reading
|
|
423
|
+
is refused with ``too_large`` once more than ``max_bytes`` bytes are seen
|
|
424
|
+
(when ``max_bytes`` is not ``None``).
|
|
425
|
+
"""
|
|
426
|
+
_require_algorithm(algorithm)
|
|
427
|
+
_require_chunk_size(chunk_size)
|
|
428
|
+
if max_bytes is not None:
|
|
429
|
+
if isinstance(max_bytes, bool) or not isinstance(max_bytes, int) or max_bytes < 0:
|
|
430
|
+
raise ValueError(f"max_bytes must be a non-negative int or None, got {max_bytes!r}")
|
|
431
|
+
|
|
432
|
+
hasher = hashlib.new(algorithm)
|
|
433
|
+
name = getattr(fileobj, "name", None)
|
|
434
|
+
size = 0
|
|
435
|
+
while True:
|
|
436
|
+
chunk = fileobj.read(chunk_size)
|
|
437
|
+
if not chunk:
|
|
438
|
+
break
|
|
439
|
+
size += len(chunk)
|
|
440
|
+
if max_bytes is not None and size > max_bytes:
|
|
441
|
+
return FileHashResult(name, algorithm, None, size, "exceeds max_bytes", True)
|
|
442
|
+
hasher.update(chunk)
|
|
443
|
+
return FileHashResult(name, algorithm, hasher.hexdigest(), size, None, False)
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
def hash_file(
|
|
447
|
+
path: str,
|
|
448
|
+
*,
|
|
449
|
+
algorithm: str = ALGORITHM,
|
|
450
|
+
chunk_size: int = DEFAULT_CHUNK_SIZE,
|
|
451
|
+
max_bytes: Optional[int] = None,
|
|
452
|
+
) -> FileHashResult:
|
|
453
|
+
"""Stream-hash a file. Expected ``OSError`` conditions are returned, not raised."""
|
|
454
|
+
_require_algorithm(algorithm)
|
|
455
|
+
_require_chunk_size(chunk_size)
|
|
456
|
+
try:
|
|
457
|
+
with _OPEN(path, "rb") as handle:
|
|
458
|
+
return hash_fileobj(
|
|
459
|
+
handle, algorithm=algorithm, chunk_size=chunk_size, max_bytes=max_bytes
|
|
460
|
+
)
|
|
461
|
+
except OSError as exc:
|
|
462
|
+
return FileHashResult(path, algorithm, None, None, str(exc), False)
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
def _stat_signature(path: str) -> Optional[_StatSig]:
|
|
466
|
+
try:
|
|
467
|
+
st = os.stat(path)
|
|
468
|
+
except OSError:
|
|
469
|
+
return None
|
|
470
|
+
mtime_ns = getattr(st, "st_mtime_ns", None)
|
|
471
|
+
if mtime_ns is None: # pragma: no cover - Windows always provides it
|
|
472
|
+
mtime_ns = int(st.st_mtime * 1_000_000_000)
|
|
473
|
+
return _StatSig(int(st.st_size), int(mtime_ns))
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
def fingerprint_file(
|
|
477
|
+
path: str,
|
|
478
|
+
*,
|
|
479
|
+
algorithm: str = ALGORITHM,
|
|
480
|
+
chunk_size: int = DEFAULT_CHUNK_SIZE,
|
|
481
|
+
max_bytes: Optional[int] = None,
|
|
482
|
+
) -> FileFingerprint:
|
|
483
|
+
"""Return a change-detection fingerprint (heuristic, not proof of identity)."""
|
|
484
|
+
_require_algorithm(algorithm)
|
|
485
|
+
sig = _stat_signature(path)
|
|
486
|
+
if sig is None:
|
|
487
|
+
return FileFingerprint(path, algorithm, None, None, None)
|
|
488
|
+
hashed = hash_file(
|
|
489
|
+
path, algorithm=algorithm, chunk_size=chunk_size, max_bytes=max_bytes
|
|
490
|
+
)
|
|
491
|
+
return FileFingerprint(path, algorithm, sig.size, hashed.digest, sig.mtime_ns)
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
# ---------------------------------------------------------------------------
|
|
495
|
+
# File verification (facts only)
|
|
496
|
+
# ---------------------------------------------------------------------------
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
def verify_file(
|
|
500
|
+
directory: str,
|
|
501
|
+
rel_path: str,
|
|
502
|
+
expected_digest,
|
|
503
|
+
*,
|
|
504
|
+
algorithm: str = ALGORITHM,
|
|
505
|
+
chunk_size: int = DEFAULT_CHUNK_SIZE,
|
|
506
|
+
max_bytes: Optional[int] = None,
|
|
507
|
+
) -> FileVerification:
|
|
508
|
+
"""Verify one declared file against ``expected_digest`` and return a fact.
|
|
509
|
+
|
|
510
|
+
Expected filesystem conditions (``OSError``) map to ``missing`` /
|
|
511
|
+
``not_a_file`` / ``unreadable``. Non-``OSError`` defects propagate.
|
|
512
|
+
Constant-time comparison is used via :func:`hmac.compare_digest`.
|
|
513
|
+
"""
|
|
514
|
+
if not isinstance(algorithm, str) or algorithm.strip().lower() not in SUPPORTED_ALGORITHMS:
|
|
515
|
+
return FileVerification(
|
|
516
|
+
rel_path, VERIFY_UNSUPPORTED, None, None, None, str(algorithm),
|
|
517
|
+
f"unsupported algorithm {algorithm!r}",
|
|
518
|
+
)
|
|
519
|
+
|
|
520
|
+
expected = manifest.normalize_hash(expected_digest)
|
|
521
|
+
if expected is None:
|
|
522
|
+
return FileVerification(
|
|
523
|
+
rel_path, VERIFY_MALFORMED, None, None, None, algorithm,
|
|
524
|
+
"expected digest is not a 64-char SHA-256 hex value",
|
|
525
|
+
)
|
|
526
|
+
|
|
527
|
+
resolution = manifest.resolve_integrity_key(rel_path, directory)
|
|
528
|
+
if not resolution.within or resolution.path is None:
|
|
529
|
+
return FileVerification(
|
|
530
|
+
rel_path, VERIFY_ESCAPE, expected, None, None, algorithm,
|
|
531
|
+
f"key does not resolve inside the manifest directory ({resolution.reason})",
|
|
532
|
+
)
|
|
533
|
+
abs_path = resolution.path
|
|
534
|
+
|
|
535
|
+
if os.path.isdir(abs_path):
|
|
536
|
+
return FileVerification(
|
|
537
|
+
rel_path, VERIFY_NOT_A_FILE, expected, None, None, algorithm,
|
|
538
|
+
"path exists but is not a regular file",
|
|
539
|
+
)
|
|
540
|
+
|
|
541
|
+
pre = _stat_signature(abs_path)
|
|
542
|
+
if pre is None:
|
|
543
|
+
if not os.path.lexists(abs_path):
|
|
544
|
+
return FileVerification(
|
|
545
|
+
rel_path, VERIFY_MISSING, expected, None, None, algorithm,
|
|
546
|
+
"declared file is absent",
|
|
547
|
+
)
|
|
548
|
+
return FileVerification(
|
|
549
|
+
rel_path, VERIFY_UNREADABLE, expected, None, None, algorithm,
|
|
550
|
+
"cannot stat declared file",
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
if max_bytes is not None and pre.size > max_bytes:
|
|
554
|
+
return FileVerification(
|
|
555
|
+
rel_path, VERIFY_TOO_LARGE, expected, None, pre.size, algorithm,
|
|
556
|
+
f"file exceeds max_bytes={max_bytes}",
|
|
557
|
+
)
|
|
558
|
+
|
|
559
|
+
try:
|
|
560
|
+
with _OPEN(abs_path, "rb") as handle:
|
|
561
|
+
hashed = hash_fileobj(
|
|
562
|
+
handle, algorithm=algorithm, chunk_size=chunk_size, max_bytes=max_bytes
|
|
563
|
+
)
|
|
564
|
+
except FileNotFoundError:
|
|
565
|
+
return FileVerification(
|
|
566
|
+
rel_path, VERIFY_MISSING, expected, None, None, algorithm,
|
|
567
|
+
"declared file is absent",
|
|
568
|
+
)
|
|
569
|
+
except OSError as exc:
|
|
570
|
+
return FileVerification(
|
|
571
|
+
rel_path, VERIFY_UNREADABLE, expected, None, None, algorithm, str(exc)
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
if hashed.too_large:
|
|
575
|
+
return FileVerification(
|
|
576
|
+
rel_path, VERIFY_TOO_LARGE, expected, None, hashed.size, algorithm,
|
|
577
|
+
"file exceeds max_bytes while hashing",
|
|
578
|
+
)
|
|
579
|
+
if hashed.digest is None:
|
|
580
|
+
return FileVerification(
|
|
581
|
+
rel_path, VERIFY_UNREADABLE, expected, None, hashed.size, algorithm, hashed.error
|
|
582
|
+
)
|
|
583
|
+
|
|
584
|
+
post = _stat_signature(abs_path)
|
|
585
|
+
if post is None:
|
|
586
|
+
return FileVerification(
|
|
587
|
+
rel_path, VERIFY_UNSTABLE, expected, hashed.digest, hashed.size, algorithm,
|
|
588
|
+
"file could not be re-statted after hashing",
|
|
589
|
+
)
|
|
590
|
+
if post != pre:
|
|
591
|
+
return FileVerification(
|
|
592
|
+
rel_path, VERIFY_UNSTABLE, expected, hashed.digest, hashed.size, algorithm,
|
|
593
|
+
"file changed while it was being hashed",
|
|
594
|
+
)
|
|
595
|
+
|
|
596
|
+
status = (
|
|
597
|
+
VERIFY_VERIFIED
|
|
598
|
+
if hmac.compare_digest(hashed.digest, expected)
|
|
599
|
+
else VERIFY_MISMATCHED
|
|
600
|
+
)
|
|
601
|
+
return FileVerification(
|
|
602
|
+
rel_path, status, expected, hashed.digest, hashed.size, algorithm, None
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
def verify_files(
|
|
607
|
+
directory: str,
|
|
608
|
+
integrity_map: Mapping[str, str],
|
|
609
|
+
*,
|
|
610
|
+
algorithm: str = ALGORITHM,
|
|
611
|
+
chunk_size: int = DEFAULT_CHUNK_SIZE,
|
|
612
|
+
max_bytes: Optional[int] = None,
|
|
613
|
+
) -> Tuple[FileVerification, ...]:
|
|
614
|
+
"""Verify every declared key, deterministically ordered by normalized path."""
|
|
615
|
+
if not isinstance(integrity_map, Mapping):
|
|
616
|
+
return ()
|
|
617
|
+
return tuple(
|
|
618
|
+
verify_file(
|
|
619
|
+
directory, key, integrity_map[key],
|
|
620
|
+
algorithm=algorithm, chunk_size=chunk_size, max_bytes=max_bytes,
|
|
621
|
+
)
|
|
622
|
+
for key in sorted(integrity_map)
|
|
623
|
+
)
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
def _fold_path_for_platform(path: str, platform: str) -> str:
|
|
627
|
+
"""Normalize an integrity path for cross-source comparison.
|
|
628
|
+
|
|
629
|
+
Separators are unified to ``/`` on all platforms. On ``nt`` the result is
|
|
630
|
+
additionally case-folded so a single physical file is never both verified
|
|
631
|
+
(through a manifest key) and reported undeclared merely because the manifest
|
|
632
|
+
and the filesystem disagree on letter case. Other platforms keep exact case.
|
|
633
|
+
"""
|
|
634
|
+
normalized = path.replace("\\", "/")
|
|
635
|
+
if platform == "nt":
|
|
636
|
+
return normalized.lower()
|
|
637
|
+
return normalized
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
def collect_undeclared(
|
|
641
|
+
directory: str,
|
|
642
|
+
integrity_map: Mapping[str, str],
|
|
643
|
+
*,
|
|
644
|
+
platform: Optional[str] = None,
|
|
645
|
+
) -> Tuple[str, ...]:
|
|
646
|
+
"""Enumerated ``.json`` node files not covered by the declared integrity map.
|
|
647
|
+
|
|
648
|
+
Comparison is case-insensitive on Windows (E3-D13/U-6 context) and exact
|
|
649
|
+
elsewhere, so a case-only mismatch between a manifest key and an on-disk file
|
|
650
|
+
does not double-count one physical file. Original on-disk spelling is
|
|
651
|
+
preserved in the returned paths for diagnostics. This does not affect
|
|
652
|
+
canonical containment, symlink rejection, or collision handling, which are
|
|
653
|
+
all performed by ``manifest``.
|
|
654
|
+
"""
|
|
655
|
+
plat = os.name if platform is None else platform
|
|
656
|
+
declared = set()
|
|
657
|
+
if isinstance(integrity_map, Mapping):
|
|
658
|
+
for key in integrity_map:
|
|
659
|
+
if isinstance(key, str):
|
|
660
|
+
declared.add(_fold_path_for_platform(key, plat))
|
|
661
|
+
return tuple(
|
|
662
|
+
path
|
|
663
|
+
for path in manifest.enumerate_node_files(directory)
|
|
664
|
+
if _fold_path_for_platform(path, plat) not in declared
|
|
665
|
+
)
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
def undeclared_verifications(
|
|
669
|
+
directory: str, rel_paths: Sequence[str], *, algorithm: str = ALGORITHM
|
|
670
|
+
) -> Tuple[FileVerification, ...]:
|
|
671
|
+
"""Represent undeclared files as ``unverified`` facts (no expected digest)."""
|
|
672
|
+
return tuple(
|
|
673
|
+
FileVerification(
|
|
674
|
+
path, VERIFY_UNVERIFIED, None, None, None, algorithm,
|
|
675
|
+
"no expected digest (undeclared file)",
|
|
676
|
+
)
|
|
677
|
+
for path in rel_paths
|
|
678
|
+
)
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
# ---------------------------------------------------------------------------
|
|
682
|
+
# Defensive manifest classification
|
|
683
|
+
# ---------------------------------------------------------------------------
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
def classify_manifest_facts(result: manifest.ManifestLoadResult) -> ManifestFacts:
|
|
687
|
+
"""Total, defensive classification of an S1 result. Never raises.
|
|
688
|
+
|
|
689
|
+
Unknown statuses and combinations S1 cannot produce are reported as explicit
|
|
690
|
+
non-policy reasons (``inconsistent`` / ``unknown_status``); they are never
|
|
691
|
+
silently mapped to ``collision_unusable`` or any other usable-policy case.
|
|
692
|
+
"""
|
|
693
|
+
st = result.status
|
|
694
|
+
usable = result.usable_for_integrity
|
|
695
|
+
info = result.info
|
|
696
|
+
|
|
697
|
+
if st not in _EXPECTED_STATUSES:
|
|
698
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_UNKNOWN_STATUS)
|
|
699
|
+
|
|
700
|
+
if st == manifest.STATUS_ABSENT:
|
|
701
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_ABSENT)
|
|
702
|
+
if st == manifest.STATUS_MALFORMED:
|
|
703
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_MALFORMED)
|
|
704
|
+
if st == manifest.STATUS_UNSUPPORTED:
|
|
705
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_UNSUPPORTED)
|
|
706
|
+
if st == manifest.STATUS_OVERSIZED:
|
|
707
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_OVERSIZED)
|
|
708
|
+
if st == manifest.STATUS_UNREADABLE:
|
|
709
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_UNREADABLE)
|
|
710
|
+
|
|
711
|
+
# st is exactly STATUS_OK from here on.
|
|
712
|
+
integrity = info.integrity if info is not None else None
|
|
713
|
+
|
|
714
|
+
if usable:
|
|
715
|
+
# S1: usable=True requires info, a non-empty map, and no collision.
|
|
716
|
+
if info is None or integrity is None or not integrity.files:
|
|
717
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_INCONSISTENT)
|
|
718
|
+
if any(issue.code in _COLLISION_ISSUE_CODES for issue in result.issues):
|
|
719
|
+
# Defensive: genuine S1 never reports usable=True with a collision.
|
|
720
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_INCONSISTENT)
|
|
721
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_USABLE)
|
|
722
|
+
|
|
723
|
+
# usable is False and status is OK -> exactly one of three well-defined cases.
|
|
724
|
+
if info is None:
|
|
725
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_INCONSISTENT)
|
|
726
|
+
if integrity is None:
|
|
727
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_MISSING_INTEGRITY)
|
|
728
|
+
if not integrity.files:
|
|
729
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_EMPTY_MAP)
|
|
730
|
+
if any(issue.code in _COLLISION_ISSUE_CODES for issue in result.issues):
|
|
731
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_COLLISION_UNUSABLE)
|
|
732
|
+
# Non-empty map, not usable, but not demonstrably collision-unusable.
|
|
733
|
+
return ManifestFacts(st, usable, MANIFEST_REASON_INCONSISTENT)
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
# ---------------------------------------------------------------------------
|
|
737
|
+
# Policy projection
|
|
738
|
+
# ---------------------------------------------------------------------------
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
def _manifest_unresolved_for_non_external(reason: str) -> str:
|
|
742
|
+
if reason == MANIFEST_REASON_MALFORMED:
|
|
743
|
+
return U1
|
|
744
|
+
if reason in (MANIFEST_REASON_MISSING_INTEGRITY, MANIFEST_REASON_EMPTY_MAP,
|
|
745
|
+
MANIFEST_REASON_COLLISION_UNUSABLE):
|
|
746
|
+
return Q_S2_4
|
|
747
|
+
return Q_S2_1
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
def evaluate_manifest_outcome(*, source_class: str, facts: ManifestFacts) -> ManifestOutcome:
|
|
751
|
+
"""Project manifest-level facts to a policy value (never invents policy)."""
|
|
752
|
+
if facts.reason in MANIFEST_REASONS_INVALID:
|
|
753
|
+
raise ManifestContractError(
|
|
754
|
+
facts.reason, f"status={facts.status!r} usable={facts.usable!r}"
|
|
755
|
+
)
|
|
756
|
+
if facts.reason not in MANIFEST_REASONS_POLICY: # pragma: no cover - contract guard
|
|
757
|
+
raise ManifestContractError(facts.reason, "reason is not a known policy reason")
|
|
758
|
+
|
|
759
|
+
if facts.reason == MANIFEST_REASON_USABLE:
|
|
760
|
+
return ManifestOutcome(POLICY_VERIFIED, facts.reason, facts.status, facts.usable, None)
|
|
761
|
+
|
|
762
|
+
if source_class == manifest.SOURCE_EXTERNAL:
|
|
763
|
+
# E3-D12: external fails closed for every non-usable manifest.
|
|
764
|
+
return ManifestOutcome(POLICY_BLOCK, facts.reason, facts.status, facts.usable, None)
|
|
765
|
+
|
|
766
|
+
code = _manifest_unresolved_for_non_external(facts.reason)
|
|
767
|
+
return ManifestOutcome(POLICY_UNRESOLVED, facts.reason, facts.status, facts.usable, code)
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
def _file_policy(verification: FileVerification, source_class: str) -> FilePolicy:
|
|
771
|
+
st = verification.status
|
|
772
|
+
path = verification.path
|
|
773
|
+
|
|
774
|
+
if st == VERIFY_VERIFIED:
|
|
775
|
+
return FilePolicy(path, POLICY_VERIFIED, None, "hash matches the declared value")
|
|
776
|
+
|
|
777
|
+
if st == VERIFY_UNVERIFIED:
|
|
778
|
+
# Undeclared file: whether a missing hash is covered is an owner question.
|
|
779
|
+
code = Q_S2_6 if source_class == manifest.SOURCE_EXTERNAL else Q_S2_5
|
|
780
|
+
return FilePolicy(path, POLICY_UNRESOLVED, code, "no expected digest (undeclared)")
|
|
781
|
+
|
|
782
|
+
if st == VERIFY_TOO_LARGE:
|
|
783
|
+
# Q-S2-8 covers the max-size mandate *and* the too_large policy.
|
|
784
|
+
return FilePolicy(path, POLICY_UNRESOLVED, Q_S2_8, "file exceeds max_bytes")
|
|
785
|
+
|
|
786
|
+
if source_class == manifest.SOURCE_EXTERNAL:
|
|
787
|
+
# E3-D5/E3-D12: only a verified hash is acceptable for external sources.
|
|
788
|
+
return FilePolicy(
|
|
789
|
+
path, POLICY_BLOCK, None,
|
|
790
|
+
f"external source requires successful verification (got {st})",
|
|
791
|
+
)
|
|
792
|
+
|
|
793
|
+
# Non-external source classes.
|
|
794
|
+
if st == VERIFY_MISMATCHED:
|
|
795
|
+
return FilePolicy(path, POLICY_BLOCK, None, "declared hash mismatch (E3-D1)")
|
|
796
|
+
if st == VERIFY_ESCAPE:
|
|
797
|
+
return FilePolicy(path, POLICY_BLOCK, None, "key escapes the manifest directory (E3-D13)")
|
|
798
|
+
if st == VERIFY_MISSING:
|
|
799
|
+
return FilePolicy(path, POLICY_UNRESOLVED, Q_S2_2, "declared file is absent")
|
|
800
|
+
if st in (VERIFY_UNREADABLE, VERIFY_UNSTABLE, VERIFY_NOT_A_FILE):
|
|
801
|
+
return FilePolicy(
|
|
802
|
+
path, POLICY_UNRESOLVED, Q_S2_3,
|
|
803
|
+
f"declared file is not a plain readable file ({st})",
|
|
804
|
+
)
|
|
805
|
+
# Defensive/uncovered states (unreachable for genuine declared files).
|
|
806
|
+
return FilePolicy(
|
|
807
|
+
path, POLICY_UNRESOLVED, UNDECIDED_CODE, f"verification state not owner-decided ({st})"
|
|
808
|
+
)
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
def apply_source_class_policy(
|
|
812
|
+
verifications: Sequence[FileVerification],
|
|
813
|
+
*,
|
|
814
|
+
source_class: str,
|
|
815
|
+
facts: ManifestFacts,
|
|
816
|
+
) -> PolicyEvaluation:
|
|
817
|
+
"""Aggregate the manifest outcome and every file policy deterministically."""
|
|
818
|
+
manifest_outcome = evaluate_manifest_outcome(source_class=source_class, facts=facts)
|
|
819
|
+
files = tuple(_file_policy(v, source_class) for v in verifications)
|
|
820
|
+
|
|
821
|
+
outcomes = (manifest_outcome,) + files
|
|
822
|
+
policies = [o.policy for o in outcomes]
|
|
823
|
+
unresolved_codes = tuple(
|
|
824
|
+
sorted({o.unresolved for o in outcomes if o.unresolved})
|
|
825
|
+
)
|
|
826
|
+
policy = next(p for p in POLICY_PRECEDENCE if p in set(policies))
|
|
827
|
+
blocked = any(p == POLICY_BLOCK for p in policies)
|
|
828
|
+
has_unresolved = any(p == POLICY_UNRESOLVED for p in policies)
|
|
829
|
+
return PolicyEvaluation(
|
|
830
|
+
policy=policy,
|
|
831
|
+
blocked=blocked,
|
|
832
|
+
has_unresolved=has_unresolved,
|
|
833
|
+
unresolved_codes=unresolved_codes,
|
|
834
|
+
manifest_outcome=manifest_outcome,
|
|
835
|
+
files=files,
|
|
836
|
+
)
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
# ---------------------------------------------------------------------------
|
|
840
|
+
# Orchestration
|
|
841
|
+
# ---------------------------------------------------------------------------
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
def verify_integrity(
|
|
845
|
+
directory: str,
|
|
846
|
+
*,
|
|
847
|
+
source_class: Optional[str] = None,
|
|
848
|
+
bundled_root: Optional[str] = None,
|
|
849
|
+
user_root: Optional[str] = None,
|
|
850
|
+
algorithm: str = ALGORITHM,
|
|
851
|
+
chunk_size: int = DEFAULT_CHUNK_SIZE,
|
|
852
|
+
max_bytes: Optional[int] = None,
|
|
853
|
+
platform: Optional[str] = None,
|
|
854
|
+
manifest_result: Optional[manifest.ManifestLoadResult] = None,
|
|
855
|
+
) -> IntegrityReport:
|
|
856
|
+
"""Verify the ``.json`` node files of ``directory`` and project policy.
|
|
857
|
+
|
|
858
|
+
Read-only and non-executing. If ``manifest_result`` is supplied it is used
|
|
859
|
+
instead of re-loading; otherwise ``manifest.load_manifest(directory,
|
|
860
|
+
platform=platform)`` is called. If ``source_class`` is ``None`` it is derived
|
|
861
|
+
from ``bundled_root``/``user_root`` plus the manifest's tighten-only
|
|
862
|
+
declaration. ``platform`` (default: the running host) is a deterministic seam
|
|
863
|
+
forwarded to manifest loading and to case-insensitive undeclared-file
|
|
864
|
+
reconciliation on Windows.
|
|
865
|
+
"""
|
|
866
|
+
result = (
|
|
867
|
+
manifest_result
|
|
868
|
+
if manifest_result is not None
|
|
869
|
+
else manifest.load_manifest(directory, platform=platform)
|
|
870
|
+
)
|
|
871
|
+
|
|
872
|
+
if source_class is None:
|
|
873
|
+
location = manifest.classify_source(
|
|
874
|
+
directory, bundled_root=bundled_root, user_root=user_root
|
|
875
|
+
)
|
|
876
|
+
source_class = manifest.tighten_source_class(location, result.info)
|
|
877
|
+
|
|
878
|
+
facts = classify_manifest_facts(result)
|
|
879
|
+
|
|
880
|
+
declared = {}
|
|
881
|
+
if result.info is not None and result.info.integrity is not None:
|
|
882
|
+
declared = dict(result.info.integrity.files)
|
|
883
|
+
|
|
884
|
+
verifications = list(
|
|
885
|
+
verify_files(
|
|
886
|
+
directory, declared,
|
|
887
|
+
algorithm=algorithm, chunk_size=chunk_size, max_bytes=max_bytes,
|
|
888
|
+
)
|
|
889
|
+
)
|
|
890
|
+
undeclared = collect_undeclared(directory, declared, platform=platform)
|
|
891
|
+
verifications.extend(undeclared_verifications(directory, undeclared, algorithm=algorithm))
|
|
892
|
+
|
|
893
|
+
evaluation = apply_source_class_policy(
|
|
894
|
+
verifications, source_class=source_class, facts=facts
|
|
895
|
+
)
|
|
896
|
+
|
|
897
|
+
issues = [_to_integrity_issue(issue) for issue in result.issues]
|
|
898
|
+
undeclared_code = (
|
|
899
|
+
Q_S2_6 if source_class == manifest.SOURCE_EXTERNAL else Q_S2_5
|
|
900
|
+
)
|
|
901
|
+
for path in undeclared:
|
|
902
|
+
issues.append(
|
|
903
|
+
IntegrityIssue(
|
|
904
|
+
"undeclared_file",
|
|
905
|
+
f"{path} is not covered by the manifest integrity map",
|
|
906
|
+
unresolved=undeclared_code,
|
|
907
|
+
)
|
|
908
|
+
)
|
|
909
|
+
|
|
910
|
+
return IntegrityReport(
|
|
911
|
+
directory=directory,
|
|
912
|
+
source_class=source_class,
|
|
913
|
+
manifest_status=result.status,
|
|
914
|
+
manifest_usable=facts.usable,
|
|
915
|
+
coverage_scope=COVERAGE_SCOPE,
|
|
916
|
+
policy=evaluation.policy,
|
|
917
|
+
blocked=evaluation.blocked,
|
|
918
|
+
has_unresolved=evaluation.has_unresolved,
|
|
919
|
+
unresolved_codes=evaluation.unresolved_codes,
|
|
920
|
+
manifest_outcome=evaluation.manifest_outcome,
|
|
921
|
+
files=tuple(verifications),
|
|
922
|
+
policies=evaluation.files,
|
|
923
|
+
undeclared=undeclared,
|
|
924
|
+
issues=tuple(issues),
|
|
925
|
+
)
|