open-horizon / anax

Horizon agent control system
https://open-horizon.github.io/docs/anax/docs/
Apache License 2.0
70 stars 99 forks source link

agent-uninstall.sh doesn't delete node if special characters are in user password #4035

Open dlarson04 opened 2 months ago

dlarson04 commented 2 months ago

Describe the bug.

Created an exchange user as follows

hzn exchange user create myuser '55;$17&421989'

that had special characters of ;, $', and & and registered an edgecluster agent with that user and then tried to run agent-uninstall as

./agent-uninstall.sh  -m dougs-ns -d -u 'myuser:55;$17&421989'

resulted in some errors in the script

++ k3s kubectl exec -it agent-747dc6744f-vj7qk -n dougs-ns -- bash -c 'export HZN_EXCHANGE_USER_AUTH=myuser:55;$17&421989; hzn node list'
Defaulted container "anax" out of: anax, initcontainer (init)
+ NODE_INFO='bash: line 1: 421989: command not found
bash: line 1: 7: command not found
{
  "id": "dougs-ns-agent",
  "organization": "ieam-roks-45",
  "pattern": "",
  "name": "dougs-ns-agent",
  "nodeType": "cluster",
  "token_last_valid_time": "2024-04-10 19:09:03 +0000 UTC",
  "token_valid": true,
  "ha_group": "",
  "configstate": {
    "state": "configured",
    "last_update_time": "2024-04-10 19:09:03 +0000 UTC"
  },
  "configuration": {
    "exchange_api": "<THE-EXCHANGE>/v1/",
    "exchange_version": "2.110.4",
    "required_minimum_exchange_version": "2.90.1",
    "preferred_exchange_version": "2.110.1",
    "mms_api": "<THE_CSS/edge-css",
    "architecture": "amd64",
    "horizon_version": "2.30.0-1496",
    "cert_file_version": "1.0.1001",
    "config_file_version": "1.0.0"
  }
'
' '}config_file_version":' '"1.0.0"",,/edge-css",exchange/v1/",
++ jq -r .configstate.state
++ sed 's/[^a-z]*//g'
parse error: Invalid numeric literal at line 1, column 5
+ NODE_STATE=
' '}config_file_version":' '"1.0.0"",,am-rokd/edge-css",exchange/v1/",
++ jq -r .id
++ sed 's/\r//g'
parse error: Invalid numeric literal at line 1, column 5
+ NODE_ID=
+ log_debug 'NODE config state for  is '

Describe the steps to reproduce the behavior.

See above

Expected behavior.

agent-uninstall should be able uninstall the edgecluster agent

Screenshots.

No response

Operating Environment

Linux

Additional Information

No response