Keeper-Security / ksm-action

Keeper Security Secrets Manager Action
MIT License
11 stars 8 forks source link

Error: Failed to parse KSM Notation: Keeper notation is invalid - first index must be numeric: [n] or []. #142

Closed rxvctw closed 4 months ago

rxvctw commented 4 months ago

Hey KSM team we are using keeper action to inject some credential but when we reference from a database credential it show as error Error: Failed to parse KSM Notation: Keeper notation is invalid - first index must be numeric: [n] or []. but it inject the right values so can you help me why this is showing as an error if in you documentation you said that that is the way to access

Run Keeper-Security/ksm-action@master with: keeper-secret-config: secrets: xxxxxx/field/login > LOGIN xxxxxx/field/password > PASSWORD xxxxx/field/host[hostName] > HOSTNAME xxxxx/field/host[port] > PORT Error: Failed to parse KSM Notation: Keeper notation is invalid - first index must be numeric: [n] or []. Error: Failed to parse KSM Notation: Keeper notation is invalid - first index must be numeric: [n] or [].

idimov-keeper commented 4 months ago

Thanks for reporting this issue - we already updated our docs on the subject. The quick fix is to always specify first/numeric index (a.k.a. predicate in our docs) - ex. xxxxx/field/host[0][hostName] and xxxxx/field/host[0][port]

Any field value is always an array (ex. "value": [] - even if it is a single string: "value": ["My Precious"]) so in order to get to the sub field (host/port) you must specify the numeric array index first - complex field example JSON

"fields": [
    { "type": "host", "value": [ {"hostName": "192.168.1.24", "port": "3306"} ] },
    { "type": "phone", "value": [ {"number": "5551234567", "type": "Home"}, {"number": "5550987654"} ] }
]

In the example above xxxxx/field/phone[0][number] will return different result from xxxxx/field/phone[1][number]

HTH