File tree Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change 4
4
5
5
## 5.0.0
6
6
7
- - [ node] fix: Events created from exception shouldnt have top-level message attribute
7
+ - ** breaking** [ node] fix: Events created from exception shouldnt have top-level message attribute
8
+ - [ utils] ref: Update wrap method to hide internal sentry flags
9
+ - [ utils] fix: Make internal Sentry flags non-enumerable in fill util
8
10
9
11
## 4.5.3
10
12
Original file line number Diff line number Diff line change @@ -113,13 +113,26 @@ export function wrap(
113
113
}
114
114
} catch ( _oO ) { } // tslint:disable-line:no-empty
115
115
116
+ fn . prototype = fn . prototype || { } ;
116
117
sentryWrapped . prototype = fn . prototype ;
117
- fn . __sentry_wrapped__ = sentryWrapped ;
118
+
119
+ Object . defineProperty ( fn , '__sentry_wrapped__' , {
120
+ enumerable : false ,
121
+ value : sentryWrapped ,
122
+ } ) ;
118
123
119
124
// Signal that this function has been wrapped/filled already
120
125
// for both debugging and to prevent it to being wrapped/filled twice
121
- sentryWrapped . __sentry__ = true ;
122
- sentryWrapped . __sentry_original__ = fn ;
126
+ Object . defineProperties ( sentryWrapped , {
127
+ __sentry__ : {
128
+ enumerable : false ,
129
+ value : true ,
130
+ } ,
131
+ __sentry_original__ : {
132
+ enumerable : false ,
133
+ value : fn ,
134
+ } ,
135
+ } ) ;
123
136
124
137
return sentryWrapped ;
125
138
}
Original file line number Diff line number Diff line change @@ -179,4 +179,21 @@ describe('wrap()', () => {
179
179
expect ( error . message ) . equal ( 'boom' ) ;
180
180
}
181
181
} ) ;
182
+
183
+ it . only ( 'internal flags shouldnt be enumerable' , ( ) => {
184
+ const fn = ( ( ) => 1337 ) as SentryWrappedFunction ;
185
+ const wrapped = wrap ( fn ) ;
186
+
187
+ // Shouldn't show up in iteration
188
+ expect ( Object . keys ( fn ) ) . to . not . include ( '__sentry__' ) ;
189
+ expect ( Object . keys ( fn ) ) . to . not . include ( '__sentry_original__' ) ;
190
+ expect ( Object . keys ( fn ) ) . to . not . include ( '__sentry_wrapped__' ) ;
191
+ expect ( Object . keys ( wrapped ) ) . to . not . include ( '__sentry__' ) ;
192
+ expect ( Object . keys ( wrapped ) ) . to . not . include ( '__sentry_original__' ) ;
193
+ expect ( Object . keys ( wrapped ) ) . to . not . include ( '__sentry_wrapped__' ) ;
194
+ // But should be accessible directly
195
+ expect ( wrapped . __sentry__ ) . to . equal ( true ) ;
196
+ expect ( wrapped . __sentry_original__ ) . to . equal ( fn ) ;
197
+ expect ( fn . __sentry_wrapped__ ) . to . equal ( wrapped ) ;
198
+ } ) ;
182
199
} ) ;
You can’t perform that action at this time.
0 commit comments