@@ -27,6 +27,18 @@ void describe('serializable error', () => {
27
27
} ) ;
28
28
} ) ;
29
29
30
+ void test ( 'that regular stack trace does not contain current working directory' , ( ) => {
31
+ const error = new Error ( 'test error' ) ;
32
+ const serializableError = new SerializableError ( error ) ;
33
+ assert . ok ( serializableError . trace ) ;
34
+ serializableError . trace ?. forEach ( ( trace ) => {
35
+ assert . ok (
36
+ trace . file . includes ( process . cwd ( ) ) == false ,
37
+ `${ process . cwd ( ) } is included in the ${ trace . file } ` ,
38
+ ) ;
39
+ } ) ;
40
+ } ) ;
41
+
30
42
void test ( 'that regular stack trace does not contain user homedir for file url paths' , ( ) => {
31
43
const error = new Error ( 'test error' ) ;
32
44
error . stack = `at methodName (${ pathToFileURL (
@@ -42,6 +54,21 @@ void describe('serializable error', () => {
42
54
} ) ;
43
55
} ) ;
44
56
57
+ void test ( 'that regular stack trace does not contain current working directory for file url paths' , ( ) => {
58
+ const error = new Error ( 'test error' ) ;
59
+ error . stack = `at methodName (${ pathToFileURL (
60
+ process . cwd ( ) ,
61
+ ) . toString ( ) } /node_modules/@aws-amplify/test-package/lib/test.js:12:34)\n`;
62
+ const serializableError = new SerializableError ( error ) ;
63
+ assert . ok ( serializableError . trace ) ;
64
+ serializableError . trace ?. forEach ( ( trace ) => {
65
+ assert . ok (
66
+ trace . file . includes ( process . cwd ( ) ) == false ,
67
+ `${ process . cwd ( ) } is included in the ${ trace . file } ` ,
68
+ ) ;
69
+ } ) ;
70
+ } ) ;
71
+
45
72
void test ( 'that if code is available it is used as the error name' , ( ) => {
46
73
const error = new ErrorWithDetailsAndCode (
47
74
'some error message' ,
@@ -125,6 +152,18 @@ void describe('serializable error', () => {
125
152
) ;
126
153
} ) ;
127
154
155
+ void test ( 'that error message does not contain current working directory' , ( ) => {
156
+ const error = new ErrorWithDetailsAndCode ( `${ process . cwd ( ) } test error` ) ;
157
+ const serializableError = new SerializableError ( error ) ;
158
+ const matches = [
159
+ ...serializableError . message . matchAll ( new RegExp ( process . cwd ( ) , 'g' ) ) ,
160
+ ] ;
161
+ assert . ok (
162
+ matches . length === 0 ,
163
+ `${ process . cwd ( ) } is included in ${ serializableError . message } ` ,
164
+ ) ;
165
+ } ) ;
166
+
128
167
void test ( 'that error message does not contain file url path with user homedir' , ( ) => {
129
168
const error = new ErrorWithDetailsAndCode (
130
169
`${ pathToFileURL ( process . cwd ( ) ) . toString ( ) } test error` ,
@@ -139,6 +178,20 @@ void describe('serializable error', () => {
139
178
) ;
140
179
} ) ;
141
180
181
+ void test ( 'that error message does not contain file url path with current working directory' , ( ) => {
182
+ const error = new ErrorWithDetailsAndCode (
183
+ `${ pathToFileURL ( process . cwd ( ) ) . toString ( ) } test error` ,
184
+ ) ;
185
+ const serializableError = new SerializableError ( error ) ;
186
+ const matches = [
187
+ ...serializableError . message . matchAll ( new RegExp ( process . cwd ( ) , 'g' ) ) ,
188
+ ] ;
189
+ assert . ok (
190
+ matches . length === 0 ,
191
+ `${ process . cwd ( ) } is included in ${ serializableError . message } ` ,
192
+ ) ;
193
+ } ) ;
194
+
142
195
void test ( 'that error details do not contain user homedir' , ( ) => {
143
196
const error = new ErrorWithDetailsAndCode (
144
197
'test error' ,
@@ -154,6 +207,21 @@ void describe('serializable error', () => {
154
207
) ;
155
208
} ) ;
156
209
210
+ void test ( 'that error details do not contain current working directory' , ( ) => {
211
+ const error = new ErrorWithDetailsAndCode (
212
+ 'test error' ,
213
+ `${ process . cwd ( ) } test details` ,
214
+ ) ;
215
+ const serializableError = new SerializableError ( error ) ;
216
+ const matches = serializableError . details
217
+ ? [ ...serializableError . details . matchAll ( new RegExp ( process . cwd ( ) , 'g' ) ) ]
218
+ : [ ] ;
219
+ assert . ok (
220
+ serializableError . details && matches . length === 0 ,
221
+ `${ process . cwd ( ) } is included in ${ serializableError . details } ` ,
222
+ ) ;
223
+ } ) ;
224
+
157
225
void test ( 'that error details do not contain file url path with user homedir' , ( ) => {
158
226
const error = new ErrorWithDetailsAndCode (
159
227
'test error' ,
@@ -169,6 +237,21 @@ void describe('serializable error', () => {
169
237
) ;
170
238
} ) ;
171
239
240
+ void test ( 'that error details do not contain file url path with current working directory' , ( ) => {
241
+ const error = new ErrorWithDetailsAndCode (
242
+ 'test error' ,
243
+ `${ pathToFileURL ( process . cwd ( ) ) . toString ( ) } test details` ,
244
+ ) ;
245
+ const serializableError = new SerializableError ( error ) ;
246
+ const matches = serializableError . details
247
+ ? [ ...serializableError . details . matchAll ( new RegExp ( process . cwd ( ) , 'g' ) ) ]
248
+ : [ ] ;
249
+ assert . ok (
250
+ serializableError . details && matches . length === 0 ,
251
+ `${ process . cwd ( ) } is included in ${ serializableError . details } ` ,
252
+ ) ;
253
+ } ) ;
254
+
172
255
void test ( 'that error details do not contain AWS ARNs or stacks' , ( ) => {
173
256
const error = new ErrorWithDetailsAndCode (
174
257
'test error' ,
0 commit comments