You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -81,12 +95,57 @@ async function selectData(data, selector) {
81
95
}
82
96
83
97
if(result.startsWith(`"`)){
84
-
result=JSON.parse(result);
98
+
// we need to strip the beginning and ending quotes otherwise it will
99
+
// always successfully parse as a JSON string
100
+
result=result.substring(1,result.length-1);
101
+
if(!isJSONString(result)){
102
+
// add the quotes back so we can parse it into a Javascript object
103
+
// to allow support for multi-line secrets. See https://github.com/hashicorp/vault-action/issues/160
104
+
result=`"${result}"`
105
+
result=JSON.parse(result);
106
+
}
107
+
}elseif(isJSONString(result)){
108
+
if(storedAsJSONData){
109
+
// Support secrets stored in Vault as pure JSON.
110
+
// See https://github.com/hashicorp/vault-action/issues/194 and https://github.com/hashicorp/vault-action/pull/173
111
+
result=JSON.stringify(result);
112
+
result=result.substring(1,result.length-1);
113
+
}else{
114
+
// Support secrets stored in Vault as JSON Strings
115
+
result=JSON.stringify(result);
116
+
result=JSON.parse(result);
117
+
}
85
118
}
86
119
returnresult;
87
120
}
88
121
122
+
/**
123
+
* isOjbect returns true if target is a Javascript object
124
+
* @param {Type} target
125
+
*/
126
+
functionisObject(target){
127
+
returntypeoftarget==='object'&&target!==null;
128
+
}
129
+
130
+
/**
131
+
* isJSONString returns true if target parses as a valid JSON string
0 commit comments