bpmax-cli 0.1.44-beta.8 → 0.1.44
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.
- package/README.md +5 -3
- package/dist/bin.js +466 -4578
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/scripts/install-skills.mjs +0 -98
- package/skills/bpmax-auth/SKILL.md +17 -6
- package/skills/bpmax-cli/SKILL.md +0 -2
- package/skills/bpmax-project/SKILL.md +2 -1
- package/skills/bpmax-shared/SKILL.md +1 -1
- package/skills/bpmax-api-platform-editor/SKILL.md +0 -321
- package/skills/bpmax-api-platform-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-api-platform-editor/references/api-doc-debug-workflow.md +0 -34
- package/skills/bpmax-api-platform-editor/references/api-proxy-shape.md +0 -41
- package/skills/bpmax-api-platform-editor/references/instance-config-shape.md +0 -41
- package/skills/bpmax-api-platform-editor/references/platform-api-map.md +0 -52
- package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +0 -32
- package/skills/bpmax-api-platform-editor/scripts/api_platform_editor_common.py +0 -1276
- package/skills/bpmax-api-platform-editor/scripts/build_submit_payload.py +0 -64
- package/skills/bpmax-api-platform-editor/scripts/capture_write_contract.py +0 -40
- package/skills/bpmax-api-platform-editor/scripts/export_layer_bundle.py +0 -212
- package/skills/bpmax-api-platform-editor/scripts/record_doc_debug_acceptance.py +0 -62
- package/skills/bpmax-api-platform-editor/scripts/submit_and_verify_layer.py +0 -75
- package/skills/bpmax-api-platform-editor/tests/test_api_platform_editor.py +0 -287
- package/skills/bpmax-builder-shared/SKILL.md +0 -44
- package/skills/bpmax-builder-shared/base_url.py +0 -81
- package/skills/bpmax-builder-shared/runtime-script-site-matrix.json +0 -71
- package/skills/bpmax-builder-shared/runtime-script-site-matrix.md +0 -34
- package/skills/bpmax-builder-shared/runtime-script-template-catalog.md +0 -123
- package/skills/bpmax-builder-shared/runtime_script_rules.py +0 -272
- package/skills/bpmax-builder-shared/skill_audit.py +0 -374
- package/skills/bpmax-builder-shared/template_script_hard_rules.py +0 -280
- package/skills/bpmax-builder-shared/tests/test_base_url.py +0 -80
- package/skills/bpmax-builder-shared/tests/test_runtime_script_rules.py +0 -115
- package/skills/bpmax-builder-shared/tests/test_skill_audit.py +0 -231
- package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +0 -281
- package/skills/bpmax-config-latest/SKILL.md +0 -71
- package/skills/bpmax-console-template-editor/SKILL.md +0 -536
- package/skills/bpmax-console-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-console-template-editor/references/filter-integration.md +0 -60
- package/skills/bpmax-console-template-editor/references/lessons-from-resume-dashboard.md +0 -114
- package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +0 -69
- package/skills/bpmax-console-template-editor/references/module-catalog.md +0 -100
- package/skills/bpmax-console-template-editor/references/runtime-page-shape.md +0 -91
- package/skills/bpmax-console-template-editor/references/template-shape.md +0 -149
- package/skills/bpmax-console-template-editor/scripts/build_submit_payload.py +0 -38
- package/skills/bpmax-console-template-editor/scripts/confirm_console_template.py +0 -33
- package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +0 -964
- package/skills/bpmax-console-template-editor/scripts/export_console_template.py +0 -99
- package/skills/bpmax-console-template-editor/scripts/lint_console_template.py +0 -46
- package/skills/bpmax-console-template-editor/scripts/submit_console_template.py +0 -99
- package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +0 -383
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +0 -600
- package/skills/bpmax-dataset-field-template-editor/references/create-request-gotchas.md +0 -25
- package/skills/bpmax-dataset-field-template-editor/references/field-classify-mapping.md +0 -35
- package/skills/bpmax-dataset-field-template-editor/references/nested-field-patterns.md +0 -24
- package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +0 -61
- package/skills/bpmax-dataset-field-template-editor/references/virtual-field-patterns.md +0 -27
- package/skills/bpmax-dataset-field-template-editor/references/work-file-to-submit-mapping.md +0 -127
- package/skills/bpmax-dataset-field-template-editor/scripts/build_submit_payload.py +0 -67
- package/skills/bpmax-dataset-field-template-editor/scripts/confirm_dataset_field.py +0 -37
- package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +0 -784
- package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +0 -62
- package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +0 -104
- package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +0 -83
- package/skills/bpmax-dataset-field-template-editor/scripts/lint_dataset_field_semantics.py +0 -35
- package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +0 -95
- package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +0 -709
- package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +0 -59
- package/skills/bpmax-dataset-template-editor/SKILL.md +0 -779
- package/skills/bpmax-dataset-template-editor/references/custom-key-usage-patterns.md +0 -18
- package/skills/bpmax-dataset-template-editor/references/dataset-script-runtime-matrix.md +0 -73
- package/skills/bpmax-dataset-template-editor/references/pre-process-script-authoring-guide.md +0 -186
- package/skills/bpmax-dataset-template-editor/references/pre-process-script-example-catalog.md +0 -106
- package/skills/bpmax-dataset-template-editor/references/runtime-gotchas.md +0 -28
- package/skills/bpmax-dataset-template-editor/references/runtime-verified-dataset-page-shape.md +0 -47
- package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +0 -23
- package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +0 -97
- package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +0 -65
- package/skills/bpmax-dataset-template-editor/scripts/build_submit_payload.py +0 -38
- package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +0 -650
- package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +0 -155
- package/skills/bpmax-dataset-template-editor/scripts/lint_dataset_template.py +0 -42
- package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +0 -43
- package/skills/bpmax-dataset-template-editor/scripts/scan_custom_key_references.py +0 -27
- package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +0 -115
- package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +0 -52
- package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +0 -39
- package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +0 -373
- package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +0 -177
- package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +0 -4
- package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +0 -60
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +0 -394
- package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +0 -5
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale.json +0 -97
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_final_v2.json +0 -105
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_main.json +0 -36
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_region.json +0 -40
- package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +0 -41
- package/skills/bpmax-e2e-flow-test-operator/references/failure-update-loop.md +0 -17
- package/skills/bpmax-e2e-flow-test-operator/references/filter-field-discovery.md +0 -40
- package/skills/bpmax-e2e-flow-test-operator/references/minimal-test-loop.md +0 -24
- package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +0 -75
- package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +0 -107
- package/skills/bpmax-e2e-flow-test-operator/references/skill-experience-coverage-matrix.md +0 -29
- package/skills/bpmax-e2e-flow-test-operator/references/stale-runtime-and-clean-sample-rules.md +0 -54
- package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +0 -83
- package/skills/bpmax-e2e-flow-test-operator/scripts/bpmax_session.py +0 -287
- package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_plan.json +0 -59
- package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_runner.py +0 -687
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +0 -121
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +0 -288
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_api_matrix.py +0 -161
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_filter_fields.py +0 -138
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_form_runtime.py +0 -396
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +0 -341
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_test_profile.py +0 -185
- package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +0 -138
- package/skills/bpmax-feishu-chat-flow-plugin-editor/SKILL.md +0 -69
- package/skills/bpmax-feishu-chat-flow-plugin-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-checklist.md +0 -42
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-recipes.md +0 -38
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-shape.md +0 -86
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/gate-lint.md +0 -68
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/hoocoo-patterns.md +0 -39
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/runtime-behavior.md +0 -41
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/script-authoring.md +0 -110
- package/skills/bpmax-feishu-chat-flow-plugin-editor/scripts/lint_feishu_chat_plugin.py +0 -278
- package/skills/bpmax-feishu-chat-flow-plugin-editor/tests/test_lint_feishu_chat_plugin.py +0 -203
- package/skills/bpmax-filter-template-editor/SKILL.md +0 -564
- package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +0 -38
- package/skills/bpmax-filter-template-editor/references/filter-and-flow-binding.md +0 -57
- package/skills/bpmax-filter-template-editor/references/filter-content-schema.md +0 -141
- package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +0 -287
- package/skills/bpmax-filter-template-editor/references/filter-runtime-patterns.md +0 -115
- package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +0 -94
- package/skills/bpmax-filter-template-editor/scripts/build_submit_payload.py +0 -25
- package/skills/bpmax-filter-template-editor/scripts/confirm_filter_template.py +0 -22
- package/skills/bpmax-filter-template-editor/scripts/export_filter_template.py +0 -57
- package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +0 -348
- package/skills/bpmax-filter-template-editor/scripts/init_create_filter_template.py +0 -8
- package/skills/bpmax-filter-template-editor/scripts/lint_filter_template_semantics.py +0 -26
- package/skills/bpmax-filter-template-editor/scripts/submit_filter_template.py +0 -62
- package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +0 -231
- package/skills/bpmax-flow-template-editor/SKILL.md +0 -1058
- package/skills/bpmax-flow-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-flow-template-editor/references/before-next-step-script-runtime-gotchas.md +0 -62
- package/skills/bpmax-flow-template-editor/references/config-surfaces-and-placeholders.md +0 -270
- package/skills/bpmax-flow-template-editor/references/diff-strategy.md +0 -67
- package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +0 -25
- package/skills/bpmax-flow-template-editor/references/flow-template-api-workflow.md +0 -174
- package/skills/bpmax-flow-template-editor/references/intent-model.md +0 -117
- package/skills/bpmax-flow-template-editor/references/lessons-from-price-plan-flow.md +0 -147
- package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +0 -97
- package/skills/bpmax-flow-template-editor/references/matrix-flow-form-nav-collaboration.md +0 -165
- package/skills/bpmax-flow-template-editor/references/payload-checklist.md +0 -133
- package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +0 -54
- package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +0 -149
- package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +0 -41
- package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +0 -155
- package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +0 -179
- package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +0 -91
- package/skills/bpmax-flow-template-editor/references/script-review-hard-rules.md +0 -93
- package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +0 -57
- package/skills/bpmax-flow-template-editor/scripts/build_submit_payload.py +0 -69
- package/skills/bpmax-flow-template-editor/scripts/confirm_flow_template.py +0 -52
- package/skills/bpmax-flow-template-editor/scripts/export_flow_template.py +0 -114
- package/skills/bpmax-flow-template-editor/scripts/flow_template_editor_common.py +0 -1084
- package/skills/bpmax-flow-template-editor/scripts/submit_flow_template.py +0 -159
- package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +0 -636
- package/skills/bpmax-form-template-editor/SKILL.md +0 -1099
- package/skills/bpmax-form-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +0 -203
- package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +0 -125
- package/skills/bpmax-form-template-editor/references/payload-checklist.md +0 -77
- package/skills/bpmax-form-template-editor/references/sub-form-patterns.md +0 -49
- package/skills/bpmax-form-template-editor/scripts/build_submit_payload.py +0 -37
- package/skills/bpmax-form-template-editor/scripts/check_form_template_consistency.py +0 -145
- package/skills/bpmax-form-template-editor/scripts/confirm_form_template.py +0 -67
- package/skills/bpmax-form-template-editor/scripts/export_form_template.py +0 -91
- package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +0 -1762
- package/skills/bpmax-form-template-editor/scripts/lint_form_template_semantics.py +0 -30
- package/skills/bpmax-form-template-editor/scripts/record_runtime_acceptance.py +0 -67
- package/skills/bpmax-form-template-editor/scripts/submit_form_template.py +0 -163
- package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +0 -1292
- package/skills/bpmax-list-template-editor/SKILL.md +0 -468
- package/skills/bpmax-list-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-list-template-editor/references/browser-page-contract.md +0 -81
- package/skills/bpmax-list-template-editor/references/content-config-shape.md +0 -148
- package/skills/bpmax-list-template-editor/references/dataset-field-mapping.md +0 -60
- package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +0 -103
- package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +0 -102
- package/skills/bpmax-list-template-editor/references/payload-checklist.md +0 -47
- package/skills/bpmax-list-template-editor/references/runtime-verified-workflow.md +0 -140
- package/skills/bpmax-list-template-editor/references/special-formats.md +0 -394
- package/skills/bpmax-list-template-editor/scripts/build_submit_payload.py +0 -37
- package/skills/bpmax-list-template-editor/scripts/confirm_list_template.py +0 -33
- package/skills/bpmax-list-template-editor/scripts/export_list_template.py +0 -89
- package/skills/bpmax-list-template-editor/scripts/fetch_data_set.py +0 -34
- package/skills/bpmax-list-template-editor/scripts/lint_list_template_semantics.py +0 -54
- package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +0 -955
- package/skills/bpmax-list-template-editor/scripts/record_acceptance.py +0 -55
- package/skills/bpmax-list-template-editor/scripts/submit_list_template.py +0 -117
- package/skills/bpmax-list-template-editor/tests/test_list_template_editor_common.py +0 -441
- package/skills/bpmax-memory-protocol/SKILL.md +0 -72
- package/skills/bpmax-nav-config-editor/SKILL.md +0 -347
- package/skills/bpmax-nav-config-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-nav-config-editor/references/api-workflow.md +0 -68
- package/skills/bpmax-nav-config-editor/references/config-shape.md +0 -78
- package/skills/bpmax-nav-config-editor/references/icon-selection.md +0 -83
- package/skills/bpmax-nav-config-editor/references/path-mapping-rules.md +0 -46
- package/skills/bpmax-nav-config-editor/references/payload-checklist.md +0 -41
- package/skills/bpmax-nav-config-editor/references/runtime-probing.md +0 -47
- package/skills/bpmax-nav-config-editor/scripts/build_submit_payload.py +0 -34
- package/skills/bpmax-nav-config-editor/scripts/confirm_nav_config.py +0 -32
- package/skills/bpmax-nav-config-editor/scripts/export_nav_config.py +0 -56
- package/skills/bpmax-nav-config-editor/scripts/lint_nav_config_semantics.py +0 -33
- package/skills/bpmax-nav-config-editor/scripts/nav_config_editor_common.py +0 -812
- package/skills/bpmax-nav-config-editor/scripts/submit_nav_config.py +0 -44
- package/skills/bpmax-nav-config-editor/scripts/verify_nav_config.py +0 -33
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor.py +0 -358
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor_common.py +0 -138
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_lint.py +0 -58
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_submit_verify.py +0 -51
- package/skills/bpmax-project-detail-template-editor/SKILL.md +0 -329
- package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-project-detail-template-editor/references/local-temp-workflow.md +0 -59
- package/skills/bpmax-project-detail-template-editor/references/module-catalog-and-config-notes.md +0 -47
- package/skills/bpmax-project-detail-template-editor/references/payload-checklist.md +0 -33
- package/skills/bpmax-project-detail-template-editor/references/project-detail-template-api-workflow.md +0 -44
- package/skills/bpmax-project-detail-template-editor/scripts/build_submit_payload.py +0 -30
- package/skills/bpmax-project-detail-template-editor/scripts/confirm_project_detail_template.py +0 -33
- package/skills/bpmax-project-detail-template-editor/scripts/export_project_detail_template.py +0 -87
- package/skills/bpmax-project-detail-template-editor/scripts/lint_project_detail_template_semantics.py +0 -37
- package/skills/bpmax-project-detail-template-editor/scripts/project_detail_template_editor_common.py +0 -507
- package/skills/bpmax-project-detail-template-editor/scripts/submit_project_detail_template.py +0 -120
- package/skills/bpmax-project-detail-template-editor/tests/test_project_detail_template_editor.py +0 -369
- package/skills/bpmax-role-editor/SKILL.md +0 -251
- package/skills/bpmax-role-editor/references/api-workflow.md +0 -30
- package/skills/bpmax-role-editor/references/runtime-page-shape.md +0 -18
- package/skills/bpmax-role-editor/references/work-file-mapping.md +0 -32
- package/skills/bpmax-role-editor/scripts/build_submit_payload.py +0 -38
- package/skills/bpmax-role-editor/scripts/confirm_role.py +0 -33
- package/skills/bpmax-role-editor/scripts/export_role.py +0 -163
- package/skills/bpmax-role-editor/scripts/lint_role_semantics.py +0 -38
- package/skills/bpmax-role-editor/scripts/role_editor_common.py +0 -1231
- package/skills/bpmax-role-editor/scripts/submit_role.py +0 -144
- package/skills/bpmax-role-editor/tests/test_role_editor.py +0 -343
- package/skills/bpmax-user-mock-operator/SKILL.md +0 -106
- package/skills/bpmax-user-mock-operator/agents/openai.yaml +0 -4
- package/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py +0 -37
- package/skills/bpmax-user-mock-operator/scripts/user_mock_operator_common.py +0 -136
- package/skills/bpmax-user-mock-operator/tests/test_user_mock_operator.py +0 -138
- package/skills/form-control-library/SKILL.md +0 -82
- package/skills/form-control-library/agents/openai.yaml +0 -4
- package/skills/form-control-library/references/form-controls.md +0 -199
- package/skills/form-control-library/references/form-template-submit-schema.md +0 -180
- package/skills/form-control-library/references/group-select-runtime.md +0 -191
- package/skills/form-control-library/scripts/rebuild_form_control_library.py +0 -55
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
|
|
4
|
-
import json
|
|
5
|
-
import re
|
|
6
|
-
from typing import Any, Dict, Iterable
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
BLOCK_MESSAGE = "ES dataset related query must not use data_set_id as the query entry"
|
|
10
|
-
PROJECT_LIST_BLOCK_MESSAGE = (
|
|
11
|
-
"Runtime scripts must not use `/bpmax/project/list` or user-scope "
|
|
12
|
-
"ESProjectList; use raw-es-search with data_set_key, backend ctx.$esQuery, "
|
|
13
|
-
"or another non-project-list helper. If the script intentionally needs the "
|
|
14
|
-
"current user's visible project list, add `bpmax-allow-user-scope-project-list: <reason>`"
|
|
15
|
-
)
|
|
16
|
-
PROJECT_LIST_COUNT_BLOCK_MESSAGE = (
|
|
17
|
-
"Runtime scripts must not use `/bpmax/project/list` count/total as an accurate total; "
|
|
18
|
-
"project/list can be capped at 10000. Use raw-es-search with track_total_hits=true"
|
|
19
|
-
)
|
|
20
|
-
QUERY_N_PLUS_ONE_BLOCK_MESSAGE = (
|
|
21
|
-
"Runtime scripts must not call raw-es-search/ctx.$esQuery/project-list inside per-row loops; "
|
|
22
|
-
"batch terms, aggregate, or precompute the lookup instead"
|
|
23
|
-
)
|
|
24
|
-
SERIAL_ORG_LOOKUP_BLOCK_MESSAGE = (
|
|
25
|
-
"Runtime scripts must not serially await /api/group, /api/form, or /api/project lookups inside loops; "
|
|
26
|
-
"batch/cache organization mappings or push stable identity keys into the fact source"
|
|
27
|
-
)
|
|
28
|
-
SQL_JOIN_BLOCK_MESSAGE = (
|
|
29
|
-
"Runtime scripts must not use complex SQL join queries for BPMAX dataset lookup; "
|
|
30
|
-
"query the needed ES dataset directly with raw-es-search + data_set_key or a verified backend helper"
|
|
31
|
-
)
|
|
32
|
-
BULK_ES_MATCH_BLOCK_MESSAGE = (
|
|
33
|
-
"Runtime scripts must not pull a large ES dataset and match rows in script; "
|
|
34
|
-
"push the match condition into raw-es-search/ctx.$esQuery and request only the needed rows"
|
|
35
|
-
)
|
|
36
|
-
FRONTEND_COUNTING_BLOCK_MESSAGE = (
|
|
37
|
-
"Runtime scripts must not pull inventory/statistical detail rows and count them in frontend loops; "
|
|
38
|
-
"use ES size:0 aggregations for inventory/counting reports"
|
|
39
|
-
)
|
|
40
|
-
WILDCARD_NON_EMPTY_BLOCK_MESSAGE = (
|
|
41
|
-
"Runtime scripts must not use wildcard '*' or '**' to test non-empty fields; "
|
|
42
|
-
"explicitly exclude empty strings or use a verified exists/term combination"
|
|
43
|
-
)
|
|
44
|
-
INVENTORY_AGG_BLOCK_MESSAGE = (
|
|
45
|
-
"dealer_inv_opt inventory reports must use raw-es-search size:0 aggregations; "
|
|
46
|
-
"do not fetch dealer_inv_opt detail rows for frontend inventory counting"
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
SQL_JOIN_PATTERN = re.compile(r"\bselect\b[\s\S]{0,800}\bjoin\b", re.IGNORECASE)
|
|
50
|
-
ES_QUERY_PATTERN = re.compile(r"raw-es-search|ctx\.\$esQuery", re.IGNORECASE)
|
|
51
|
-
PROJECT_LIST_PATTERN = re.compile(r"/bpmax/project/list|ESProjectList|esProjectList")
|
|
52
|
-
USER_SCOPE_PROJECT_LIST_ALLOW_PATTERN = re.compile(r"bpmax-allow-user-scope-project-list\s*:")
|
|
53
|
-
ES_SIZE_PATTERN = re.compile(r"\bsize\s*:\s*(\d{3,})\b")
|
|
54
|
-
SCRIPT_MATCH_PATTERN = re.compile(r"\.(?:find|filter|some)\s*\(|\.includes\s*\(")
|
|
55
|
-
FRONTEND_COUNTING_PATTERN = re.compile(r"\b(?:inventoryQty|currentInventory|currentStock|total_count|count)\s*(?:\+\+|\+=\s*1)")
|
|
56
|
-
PROJECT_LIST_COUNT_PATTERN = re.compile(
|
|
57
|
-
r"/bpmax/project/list[\s\S]{0,800}\b(?:count|total)\b|\b(?:count|total)\b[\s\S]{0,800}/bpmax/project/list",
|
|
58
|
-
re.IGNORECASE,
|
|
59
|
-
)
|
|
60
|
-
LOOP_QUERY_PATTERN = re.compile(
|
|
61
|
-
r"\b(?:for\s*\(|for\s+await\s*\(|forEach\s*\(|map\s*\()[\s\S]{0,1600}"
|
|
62
|
-
r"(?:raw-es-search|ctx\.\$esQuery|/bpmax/project/list|ESProjectList|esProjectList)",
|
|
63
|
-
re.IGNORECASE,
|
|
64
|
-
)
|
|
65
|
-
SERIAL_ORG_LOOKUP_PATTERN = re.compile(
|
|
66
|
-
r"\b(?:for\s*\(|for\s+await\s*\(|forEach\s*\(|map\s*\()[\s\S]{0,1600}"
|
|
67
|
-
r"await[\s\S]{0,400}(?:/api/group|/api/form|/api/project)",
|
|
68
|
-
re.IGNORECASE,
|
|
69
|
-
)
|
|
70
|
-
WILDCARD_STAR_PATTERN = re.compile(
|
|
71
|
-
r"wildcard[\s\S]{0,160}value\s*:\s*['\"]\*{1,2}['\"](?!\s*\+)",
|
|
72
|
-
re.IGNORECASE,
|
|
73
|
-
)
|
|
74
|
-
DEALER_INV_OPT_PATTERN = re.compile(r"data_set_key\s*:\s*['\"]dealer_inv_opt['\"]|['\"]data_set_key['\"]\s*:\s*['\"]dealer_inv_opt['\"]")
|
|
75
|
-
SIZE_ZERO_PATTERN = re.compile(r"\bsize\s*:\s*0\b|['\"]size['\"]\s*:\s*0")
|
|
76
|
-
AGGS_PATTERN = re.compile(r"\baggs\s*:|['\"]aggs['\"]\s*:|\baggregations\b")
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def _compact(value: Any) -> str:
|
|
80
|
-
if isinstance(value, str):
|
|
81
|
-
return value
|
|
82
|
-
return json.dumps(value, ensure_ascii=False, sort_keys=True)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
def _walk(value: Any, *, prefix: str) -> Iterable[tuple[str, Any]]:
|
|
86
|
-
if isinstance(value, dict):
|
|
87
|
-
for key, child in value.items():
|
|
88
|
-
child_prefix = f"{prefix}.{key}" if prefix else str(key)
|
|
89
|
-
yield child_prefix, child
|
|
90
|
-
yield from _walk(child, prefix=child_prefix)
|
|
91
|
-
elif isinstance(value, list):
|
|
92
|
-
for idx, child in enumerate(value):
|
|
93
|
-
child_prefix = f"{prefix}[{idx}]"
|
|
94
|
-
yield child_prefix, child
|
|
95
|
-
yield from _walk(child, prefix=child_prefix)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def contains_user_scope_project_list_query(text: str) -> bool:
|
|
99
|
-
if USER_SCOPE_PROJECT_LIST_ALLOW_PATTERN.search(text):
|
|
100
|
-
return False
|
|
101
|
-
return bool(PROJECT_LIST_PATTERN.search(text))
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
def contains_root_user_project_list_helper(text: str) -> bool:
|
|
105
|
-
if "ESProjectList" not in text and "esProjectList" not in text:
|
|
106
|
-
return False
|
|
107
|
-
return any(token in text for token in ("rootUser", "root_user"))
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
def contains_large_es_pull_then_script_matching(text: str) -> bool:
|
|
111
|
-
if not ES_QUERY_PATTERN.search(text) or not SCRIPT_MATCH_PATTERN.search(text):
|
|
112
|
-
return False
|
|
113
|
-
return any(int(match.group(1)) >= 500 for match in ES_SIZE_PATTERN.finditer(text))
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
def contains_frontend_detail_counting(text: str) -> bool:
|
|
117
|
-
if not FRONTEND_COUNTING_PATTERN.search(text):
|
|
118
|
-
return False
|
|
119
|
-
if DEALER_INV_OPT_PATTERN.search(text):
|
|
120
|
-
return True
|
|
121
|
-
return any(int(match.group(1)) >= 500 for match in ES_SIZE_PATTERN.finditer(text))
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
def contains_dealer_inventory_detail_query(text: str) -> bool:
|
|
125
|
-
if not DEALER_INV_OPT_PATTERN.search(text):
|
|
126
|
-
return False
|
|
127
|
-
if not ("flow956693507" in text or "dealer_inv_opt" in text):
|
|
128
|
-
return False
|
|
129
|
-
return not (SIZE_ZERO_PATTERN.search(text) and AGGS_PATTERN.search(text))
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
def contains_project_list_count_total(text: str) -> bool:
|
|
133
|
-
return bool(PROJECT_LIST_COUNT_PATTERN.search(text))
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
def contains_loop_query(text: str) -> bool:
|
|
137
|
-
return bool(LOOP_QUERY_PATTERN.search(text))
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
def contains_serial_org_lookup(text: str) -> bool:
|
|
141
|
-
return bool(SERIAL_ORG_LOOKUP_PATTERN.search(text))
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
def _finding(path: str, rule: str, snippet: str, *, message: str = BLOCK_MESSAGE) -> Dict[str, str]:
|
|
145
|
-
return {
|
|
146
|
-
"path": path,
|
|
147
|
-
"rule": rule,
|
|
148
|
-
"message": message,
|
|
149
|
-
"snippet": snippet[:240],
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
def _scan_text(text: str, path: str) -> list[Dict[str, str]]:
|
|
154
|
-
findings: list[Dict[str, str]] = []
|
|
155
|
-
if contains_user_scope_project_list_query(text):
|
|
156
|
-
findings.append(
|
|
157
|
-
_finding(
|
|
158
|
-
path,
|
|
159
|
-
"project_list_forbidden",
|
|
160
|
-
text,
|
|
161
|
-
message=PROJECT_LIST_BLOCK_MESSAGE,
|
|
162
|
-
)
|
|
163
|
-
)
|
|
164
|
-
if contains_project_list_count_total(text):
|
|
165
|
-
findings.append(
|
|
166
|
-
_finding(
|
|
167
|
-
path,
|
|
168
|
-
"project_list_count_total_capped",
|
|
169
|
-
text,
|
|
170
|
-
message=PROJECT_LIST_COUNT_BLOCK_MESSAGE,
|
|
171
|
-
)
|
|
172
|
-
)
|
|
173
|
-
if contains_loop_query(text):
|
|
174
|
-
findings.append(
|
|
175
|
-
_finding(
|
|
176
|
-
path,
|
|
177
|
-
"query_inside_loop",
|
|
178
|
-
text,
|
|
179
|
-
message=QUERY_N_PLUS_ONE_BLOCK_MESSAGE,
|
|
180
|
-
)
|
|
181
|
-
)
|
|
182
|
-
if contains_serial_org_lookup(text):
|
|
183
|
-
findings.append(
|
|
184
|
-
_finding(
|
|
185
|
-
path,
|
|
186
|
-
"serial_org_lookup_inside_loop",
|
|
187
|
-
text,
|
|
188
|
-
message=SERIAL_ORG_LOOKUP_BLOCK_MESSAGE,
|
|
189
|
-
)
|
|
190
|
-
)
|
|
191
|
-
if SQL_JOIN_PATTERN.search(text):
|
|
192
|
-
findings.append(
|
|
193
|
-
_finding(
|
|
194
|
-
path,
|
|
195
|
-
"sql_join_forbidden",
|
|
196
|
-
text,
|
|
197
|
-
message=SQL_JOIN_BLOCK_MESSAGE,
|
|
198
|
-
)
|
|
199
|
-
)
|
|
200
|
-
if contains_large_es_pull_then_script_matching(text):
|
|
201
|
-
findings.append(
|
|
202
|
-
_finding(
|
|
203
|
-
path,
|
|
204
|
-
"bulk_es_script_matching",
|
|
205
|
-
text,
|
|
206
|
-
message=BULK_ES_MATCH_BLOCK_MESSAGE,
|
|
207
|
-
)
|
|
208
|
-
)
|
|
209
|
-
if contains_frontend_detail_counting(text):
|
|
210
|
-
findings.append(
|
|
211
|
-
_finding(
|
|
212
|
-
path,
|
|
213
|
-
"frontend_detail_counting",
|
|
214
|
-
text,
|
|
215
|
-
message=FRONTEND_COUNTING_BLOCK_MESSAGE,
|
|
216
|
-
)
|
|
217
|
-
)
|
|
218
|
-
if WILDCARD_STAR_PATTERN.search(text):
|
|
219
|
-
findings.append(
|
|
220
|
-
_finding(
|
|
221
|
-
path,
|
|
222
|
-
"wildcard_star_non_empty",
|
|
223
|
-
text,
|
|
224
|
-
message=WILDCARD_NON_EMPTY_BLOCK_MESSAGE,
|
|
225
|
-
)
|
|
226
|
-
)
|
|
227
|
-
if contains_dealer_inventory_detail_query(text):
|
|
228
|
-
findings.append(
|
|
229
|
-
_finding(
|
|
230
|
-
path,
|
|
231
|
-
"dealer_inv_opt_without_aggregation",
|
|
232
|
-
text,
|
|
233
|
-
message=INVENTORY_AGG_BLOCK_MESSAGE,
|
|
234
|
-
)
|
|
235
|
-
)
|
|
236
|
-
if "data_set_id" not in text:
|
|
237
|
-
return findings
|
|
238
|
-
if "/bpmax/project/list" in text:
|
|
239
|
-
findings.append(_finding(path, "project_list_data_set_id", text))
|
|
240
|
-
elif "/bpmax/project/raw-es-search" in text or "raw-es-search" in text:
|
|
241
|
-
findings.append(_finding(path, "raw_es_search_data_set_id", text))
|
|
242
|
-
elif "ctx.$esQuery" in text:
|
|
243
|
-
findings.append(_finding(path, "es_query_data_set_id", text))
|
|
244
|
-
elif "ESProjectList" in text or "esProjectList" in text:
|
|
245
|
-
findings.append(_finding(path, "es_project_list_data_set_id", text))
|
|
246
|
-
elif any(token in path for token in ("content.beforeSearch", "content.customQuery", "content.tabFilters", "content.config")):
|
|
247
|
-
findings.append(_finding(path, "structured_query_data_set_id", text))
|
|
248
|
-
return findings
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
def scan_named_script_surfaces(surfaces: Iterable[Dict[str, Any]]) -> Dict[str, Any]:
|
|
252
|
-
findings: list[Dict[str, str]] = []
|
|
253
|
-
for surface in surfaces:
|
|
254
|
-
path = str(surface.get("path") or "").strip()
|
|
255
|
-
if not path:
|
|
256
|
-
continue
|
|
257
|
-
script = surface.get("script")
|
|
258
|
-
if isinstance(script, str):
|
|
259
|
-
findings.extend(_scan_text(script, path))
|
|
260
|
-
if "value" not in surface:
|
|
261
|
-
continue
|
|
262
|
-
for child_path, child in _walk(surface.get("value"), prefix=path):
|
|
263
|
-
if isinstance(child, str):
|
|
264
|
-
findings.extend(_scan_text(child, child_path))
|
|
265
|
-
elif isinstance(child, dict) and "data_set_id" in child:
|
|
266
|
-
findings.append(_finding(child_path, "structured_query_data_set_id", _compact(child)))
|
|
267
|
-
|
|
268
|
-
deduped: list[Dict[str, str]] = []
|
|
269
|
-
seen: set[tuple[str, str, str]] = set()
|
|
270
|
-
for finding in findings:
|
|
271
|
-
key = (finding["path"], finding["rule"], finding["snippet"])
|
|
272
|
-
if key in seen:
|
|
273
|
-
continue
|
|
274
|
-
seen.add(key)
|
|
275
|
-
deduped.append(finding)
|
|
276
|
-
return {
|
|
277
|
-
"ok": not deduped,
|
|
278
|
-
"errors": [f"{item['path']}: {item['message']}" for item in deduped],
|
|
279
|
-
"findings": deduped,
|
|
280
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import sys
|
|
3
|
-
import tempfile
|
|
4
|
-
import unittest
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from unittest import mock
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
SHARED_DIR = Path(__file__).resolve().parents[1]
|
|
10
|
-
if str(SHARED_DIR) not in sys.path:
|
|
11
|
-
sys.path.insert(0, str(SHARED_DIR))
|
|
12
|
-
|
|
13
|
-
from base_url import BASE_URL_ENV_VAR, load_agents_default_origin, resolve_base_url # noqa: E402
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class BaseUrlResolutionTests(unittest.TestCase):
|
|
17
|
-
def test_explicit_base_url_wins_over_environment(self) -> None:
|
|
18
|
-
with mock.patch.dict(os.environ, {BASE_URL_ENV_VAR: "https://env.example.com"}, clear=False):
|
|
19
|
-
self.assertEqual(resolve_base_url("https://cli.example.com/"), "https://cli.example.com")
|
|
20
|
-
|
|
21
|
-
def test_environment_base_url_is_used_when_cli_value_missing(self) -> None:
|
|
22
|
-
with mock.patch.dict(os.environ, {BASE_URL_ENV_VAR: "https://env.example.com/"}, clear=False):
|
|
23
|
-
self.assertEqual(resolve_base_url(None), "https://env.example.com")
|
|
24
|
-
|
|
25
|
-
def test_browser_origin_is_used_when_cli_and_environment_missing(self) -> None:
|
|
26
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
27
|
-
agents_path = Path(tmpdir) / "AGENTS.md"
|
|
28
|
-
agents_path.write_text("", encoding="utf-8")
|
|
29
|
-
with mock.patch.dict(os.environ, {}, clear=True):
|
|
30
|
-
self.assertEqual(
|
|
31
|
-
resolve_base_url(None, browser_origin="https://browser.example.com/api", agents_path=agents_path),
|
|
32
|
-
"https://browser.example.com",
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
def test_agents_default_origin_is_used_as_last_fallback(self) -> None:
|
|
36
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
37
|
-
agents_path = Path(tmpdir) / "AGENTS.md"
|
|
38
|
-
agents_path.write_text(
|
|
39
|
-
"\n".join(
|
|
40
|
-
[
|
|
41
|
-
"## BPMAX Default Address Contract",
|
|
42
|
-
"<!-- BPMAX_DEFAULT_ORIGIN_CONTRACT",
|
|
43
|
-
'{"version":1,"default_origin":"https://repo.example.com","resolution_priority":["--base-url","BPMAX_BASE_URL","current_browser_origin","agents_default_origin"]}',
|
|
44
|
-
"-->",
|
|
45
|
-
]
|
|
46
|
-
),
|
|
47
|
-
encoding="utf-8",
|
|
48
|
-
)
|
|
49
|
-
with mock.patch.dict(os.environ, {}, clear=True):
|
|
50
|
-
self.assertEqual(resolve_base_url(None, agents_path=agents_path), "https://repo.example.com")
|
|
51
|
-
|
|
52
|
-
def test_repo_without_agents_contract_has_no_default_origin(self) -> None:
|
|
53
|
-
self.assertEqual(load_agents_default_origin(), "")
|
|
54
|
-
|
|
55
|
-
def test_missing_base_url_raises_actionable_error(self) -> None:
|
|
56
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
57
|
-
agents_path = Path(tmpdir) / "AGENTS.md"
|
|
58
|
-
agents_path.write_text("", encoding="utf-8")
|
|
59
|
-
with mock.patch.dict(os.environ, {}, clear=True):
|
|
60
|
-
with self.assertRaises(SystemExit) as ctx:
|
|
61
|
-
resolve_base_url(None, agents_path=agents_path)
|
|
62
|
-
self.assertIn("BPMAX_BASE_URL", str(ctx.exception))
|
|
63
|
-
self.assertIn("AGENTS.md", str(ctx.exception))
|
|
64
|
-
|
|
65
|
-
def test_invalid_nested_browser_origin_is_rejected(self) -> None:
|
|
66
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
67
|
-
agents_path = Path(tmpdir) / "AGENTS.md"
|
|
68
|
-
agents_path.write_text("", encoding="utf-8")
|
|
69
|
-
with mock.patch.dict(os.environ, {}, clear=True):
|
|
70
|
-
with self.assertRaises(SystemExit) as ctx:
|
|
71
|
-
resolve_base_url(None, browser_origin="https://browser.example.com/app/detail", agents_path=agents_path)
|
|
72
|
-
self.assertIn("nested path", str(ctx.exception))
|
|
73
|
-
|
|
74
|
-
def test_console_mode_normalizes_api_suffix_back_to_app_origin(self) -> None:
|
|
75
|
-
with mock.patch.dict(os.environ, {}, clear=True):
|
|
76
|
-
self.assertEqual(resolve_base_url("https://host.example.com/api"), "https://host.example.com")
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if __name__ == "__main__":
|
|
80
|
-
unittest.main()
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
import unittest
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
SCRIPT_DIR = Path(__file__).resolve().parents[1]
|
|
9
|
-
if str(SCRIPT_DIR) not in sys.path:
|
|
10
|
-
sys.path.insert(0, str(SCRIPT_DIR))
|
|
11
|
-
|
|
12
|
-
try:
|
|
13
|
-
from runtime_script_rules import lint_runtime_script # type: ignore
|
|
14
|
-
except ImportError:
|
|
15
|
-
lint_runtime_script = None
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def build_lines(prefix: str, count: int) -> str:
|
|
19
|
-
return "\n".join(f"{prefix} {idx};" for idx in range(count))
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class RuntimeScriptRulesTests(unittest.TestCase):
|
|
23
|
-
def test_lambda_over_budget_requires_split(self) -> None:
|
|
24
|
-
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
25
|
-
source = build_lines("const line =", 41)
|
|
26
|
-
report = lint_runtime_script("lambda", source)
|
|
27
|
-
self.assertFalse(report["ok"])
|
|
28
|
-
self.assertTrue(any(finding["code"] == "line_budget_exceeded" for finding in report["findings"]))
|
|
29
|
-
self.assertTrue(any("helper" in error or "映射表" in error for error in report["errors"]))
|
|
30
|
-
|
|
31
|
-
def test_lambda_rejects_top_level_await_without_wrapper(self) -> None:
|
|
32
|
-
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
33
|
-
source = "const resp = await ctx.$axios.post('/bpmax/project/raw-es-search');\nctx.$setValueByKeyToValue({ sn: 'x' });"
|
|
34
|
-
report = lint_runtime_script("lambda", source)
|
|
35
|
-
self.assertFalse(report["ok"])
|
|
36
|
-
self.assertTrue(any(finding["code"] == "await_requires_wrapper" for finding in report["findings"]))
|
|
37
|
-
|
|
38
|
-
def test_lambda_rejects_await_outside_wrapper_even_if_wrapper_exists_elsewhere(self) -> None:
|
|
39
|
-
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
40
|
-
source = "\n".join(
|
|
41
|
-
[
|
|
42
|
-
"const resp = await ctx.$axios.post('/bpmax/project/raw-es-search');",
|
|
43
|
-
"return (async () => {",
|
|
44
|
-
" return '';",
|
|
45
|
-
"})();",
|
|
46
|
-
]
|
|
47
|
-
)
|
|
48
|
-
report = lint_runtime_script("lambda", source)
|
|
49
|
-
self.assertFalse(report["ok"])
|
|
50
|
-
self.assertTrue(any(finding["code"] == "await_requires_wrapper" for finding in report["findings"]))
|
|
51
|
-
|
|
52
|
-
def test_project_create_validator_rejects_then_chain(self) -> None:
|
|
53
|
-
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
54
|
-
source = "return ctx.$query('select 1').then((rows) => rows.length ? '' : '缺数据');"
|
|
55
|
-
report = lint_runtime_script("project_create_validator", source)
|
|
56
|
-
self.assertFalse(report["ok"])
|
|
57
|
-
self.assertTrue(any(finding["code"] == "forbidden_promise_then" for finding in report["findings"]))
|
|
58
|
-
|
|
59
|
-
def test_lambda_rejects_project_list(self) -> None:
|
|
60
|
-
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
61
|
-
source = "return ctx.$axios.post('/bpmax/project/list?page=1', { flow_type: 'flow1', query: {} });"
|
|
62
|
-
report = lint_runtime_script("lambda", source)
|
|
63
|
-
self.assertFalse(report["ok"])
|
|
64
|
-
self.assertTrue(any(finding["code"] == "project_list_forbidden" for finding in report["findings"]))
|
|
65
|
-
|
|
66
|
-
def test_project_create_validator_rejects_sql_join(self) -> None:
|
|
67
|
-
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
68
|
-
source = (
|
|
69
|
-
"return (async () => {\n"
|
|
70
|
-
" const rows = await ctx.$query(`select p.id from think_project p "
|
|
71
|
-
"join think_form f on p.id = f.project_id where f.sn = '${sn}'`);\n"
|
|
72
|
-
" return rows.length ? '' : 'SN不存在';\n"
|
|
73
|
-
"})();"
|
|
74
|
-
)
|
|
75
|
-
report = lint_runtime_script("project_create_validator", source)
|
|
76
|
-
self.assertFalse(report["ok"])
|
|
77
|
-
self.assertTrue(any(finding["code"] == "sql_join_forbidden" for finding in report["findings"]))
|
|
78
|
-
|
|
79
|
-
def test_lambda_rejects_large_es_pull_then_script_matching(self) -> None:
|
|
80
|
-
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
81
|
-
source = "\n".join(
|
|
82
|
-
[
|
|
83
|
-
"return (async () => {",
|
|
84
|
-
" const response = await ctx.$axios.post('/bpmax/project/raw-es-search', {",
|
|
85
|
-
" flow_type: 'flow1',",
|
|
86
|
-
" data_set_key: 'inventory',",
|
|
87
|
-
" body: { query: { match_all: {} }, size: 10000 },",
|
|
88
|
-
" });",
|
|
89
|
-
" const match = response.data.data.hits.hits.find((hit) => hit._source.sn === sn);",
|
|
90
|
-
" return match ? '' : 'SN不存在';",
|
|
91
|
-
"})();",
|
|
92
|
-
]
|
|
93
|
-
)
|
|
94
|
-
report = lint_runtime_script("lambda", source)
|
|
95
|
-
self.assertFalse(report["ok"])
|
|
96
|
-
self.assertTrue(any(finding["code"] == "bulk_es_script_matching" for finding in report["findings"]))
|
|
97
|
-
|
|
98
|
-
def test_pre_process_script_accepts_async_await(self) -> None:
|
|
99
|
-
self.assertIsNotNone(lint_runtime_script, "runtime_script_rules module should exist")
|
|
100
|
-
source = "\n".join(
|
|
101
|
-
[
|
|
102
|
-
"const rows = await ctx.$esQuery({",
|
|
103
|
-
" data_set_key: 'matrix',",
|
|
104
|
-
" flow_type: 'flow160679070',",
|
|
105
|
-
" body: { query: { bool: { must: [] } } },",
|
|
106
|
-
"});",
|
|
107
|
-
"ctx.body.query.bool.must.push({ terms: { project_id: rows.map((row) => row.__id) } });",
|
|
108
|
-
]
|
|
109
|
-
)
|
|
110
|
-
report = lint_runtime_script("pre_process_script", source)
|
|
111
|
-
self.assertTrue(report["ok"], report["errors"])
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if __name__ == "__main__":
|
|
115
|
-
unittest.main()
|