mitre / caldera

Automated Adversary Emulation Platform
https://caldera.mitre.org
Apache License 2.0
5.34k stars 1.03k forks source link

Build failed with error Cannot assign to "envs" because it is a constant. #2938

Open restarbuck101 opened 3 months ago

restarbuck101 commented 3 months ago

Describe the bug Build failed with error Cannot assign to "envs" because it is a constant script:/home/geeseman/caldera/plugins/magma/src/plugins/builder/views/builder.vue?id=0:9:4: ERROR: Cannot assign to "envs" because it is a constant vite v2.9.15 dev server running at: The issue arises from attempting to reassign a value to a constant variable that was intended to be a reactive reference.

To Reproduce Executing Caldera with the following 4 commands in your terminal. 1.git clone https://github.com/mitre/caldera.git --recursive 2.cd caldera 3.pip3 install -r requirements.txt 4.python3 server.py --insecure --build

Expected behavior The expected behavior was that the envs reactive reference would be updated with the new value fetched from $api.get("/plugin/builder/environment"), allowing the component to react to the updated state. The process should not result in build errors, and the development server should start without issues.

Screenshots Build failed with 2 errors: script:/caldera/plugins/builder/gui/views/builder.vue?id=0:9:4: ERROR: Cannot assign to "envs" because it is a constant script:/home/geeseman/caldera/plugins/magma/src/plugins/builder/views/builder.vue?id=0:9:4: ERROR: Cannot assign to "envs" because it is a constant vite v2.9.15 dev server running at: > Local: http://localhost:3000/

Network: http://10.2.0.7:3000/

ready in 261ms.

✘ [ERROR] Cannot assign to "envs" because it is a constant

script:/home/caldera/plugins/magma/src/plugins/builder/views/builder.vue?id=0:9:4:
9 │     envs = await $api.get("/plugin/builder/environment");
    ╵     ~~~~

The symbol "envs" was declared a constant here:

script:/home//caldera/plugins/magma/src/plugins/builder/views/builder.vue?id=0:5:6:
5 │ const envs = ref();
    ╵       ~~~~

✘ [ERROR] Cannot assign to "envs" because it is a constant

script:/home/geeseman/caldera/plugins/builder/gui/views/builder.vue?id=0:9:4:
9 │     envs = await $api.get("/plugin/builder/environment");
    ╵     ~~~~

The symbol "envs" was declared a constant here:

script:/home/caldera/plugins/builder/gui/views/builder.vue?id=0:5:6:
5 │ const envs = ref();
    ╵       ~~~~

Desktop (please complete the following information):

Additional context This issue is highlighted in both instances within your project's Vue component files:

/caldera/plugins/builder/gui/views/builder.vue /caldera/plugins/magma/src/plugins/builder/views/builder.vue

Proposed solution: Update a reactive reference by accessing its .value property, not by reassigning the reference itself. This approach adheres to the Vue.js Composition API's design, allowing you to maintain reactivity while conforming to JavaScript's const constraints.

For the builder.vue and any similar files , update the code as follows

Before: const envs = ref();envs = await $api.get("/plugin/builder/environment");

After: const envs = ref();envs.value = await $api.get("/plugin/builder/environment");

By modifying the code as suggested, you update the reactive state of envs without attempting to reassign the const, thereby avoiding the build errors.

github-actions[bot] commented 3 months ago

Looks like your first issue -- we aim to respond to issues as quickly as possible. In the meantime, check out our documentation here: http://caldera.readthedocs.io/

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days