88import {
99 HttpRecorder ,
1010 HttpRecorderConfig ,
11- RedactionContext ,
11+ type RedactionContext ,
1212 RedactionResult ,
1313} from '@akoenig/effect-http-recorder'
1414import { Command , Options } from '@effect/cli'
@@ -81,7 +81,7 @@ const createGitHubRedactionEffect = (context: RedactionContext) => {
8181/**
8282 * Recursively redact sensitive data while preserving GitHub API data structure
8383 */
84- const redactGitHubData = ( obj : any ) : any => {
84+ const redactGitHubData = ( obj : unknown ) : unknown => {
8585 if ( ! obj || typeof obj !== 'object' ) {
8686 return obj
8787 }
@@ -90,7 +90,7 @@ const redactGitHubData = (obj: any): any => {
9090 return obj . map ( redactGitHubData )
9191 }
9292
93- const redacted = { ...obj }
93+ const redacted = { ...( obj as Record < string , unknown > ) }
9494
9595 // IDs and unique identifiers
9696 if (
@@ -204,28 +204,28 @@ const redactGitHubData = (obj: any): any => {
204204 if ( 'url' in redacted && typeof redacted . url === 'string' ) {
205205 redacted . url = redacted . url
206206 // Replace GitHub.com URLs
207- . replace ( / g i t h u b \. c o m \/ [ ^ \ /] + / g, 'github.com/example-user' )
207+ . replace ( / g i t h u b \. c o m \/ [ ^ / ] + / g, 'github.com/example-user' )
208208 // Replace API URLs - handle all patterns
209209 . replace (
210- / a p i \. g i t h u b \. c o m \/ r e p o s \/ [ ^ \ /] + \/ [ ^ \ /] + / g,
210+ / a p i \. g i t h u b \. c o m \/ r e p o s \/ [ ^ / ] + \/ [ ^ / ] + / g,
211211 'api.github.com/repos/example-user/example-repo' ,
212212 )
213213 . replace (
214- / a p i \. g i t h u b \. c o m \/ u s e r s \/ [ ^ \ /] + / g,
214+ / a p i \. g i t h u b \. c o m \/ u s e r s \/ [ ^ / ] + / g,
215215 'api.github.com/users/example-user' ,
216216 )
217217 . replace (
218- / a p i \. g i t h u b \. c o m \/ o r g s \/ [ ^ \ /] + / g,
218+ / a p i \. g i t h u b \. c o m \/ o r g s \/ [ ^ / ] + / g,
219219 'api.github.com/orgs/example-org' ,
220220 )
221221 // Handle the pattern: api.github.com/example-user/{actual-username}/{repo-name}
222222 . replace (
223- / a p i \. g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ \ /] + \/ [ ^ \ /] + / g,
223+ / a p i \. g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ / ] + \/ [ ^ / ] + / g,
224224 'api.github.com/repos/example-user/example-repo' ,
225225 )
226226 // Handle the pattern: api.github.com/example-user/{actual-username}
227227 . replace (
228- / a p i \. g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ \ /] + $ / g,
228+ / a p i \. g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ / ] + $ / g,
229229 'api.github.com/users/example-user' ,
230230 )
231231 // Replace PR and issue numbers
@@ -234,42 +234,42 @@ const redactGitHubData = (obj: any): any => {
234234 }
235235 if ( 'html_url' in redacted && typeof redacted . html_url === 'string' ) {
236236 redacted . html_url = redacted . html_url
237- . replace ( / g i t h u b \. c o m \/ [ ^ \ /] + / g, 'github.com/example-user' )
237+ . replace ( / g i t h u b \. c o m \/ [ ^ / ] + / g, 'github.com/example-user' )
238238 // Handle patterns where example-user is already present
239239 . replace (
240- / g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ \ /] + / g,
240+ / g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ / ] + / g,
241241 'github.com/example-user/example-repo' ,
242242 )
243243 }
244244 if ( 'clone_url' in redacted && typeof redacted . clone_url === 'string' ) {
245245 redacted . clone_url = redacted . clone_url
246- . replace ( / g i t h u b \. c o m \/ [ ^ \ /] + / g, 'github.com/example-user' )
246+ . replace ( / g i t h u b \. c o m \/ [ ^ / ] + / g, 'github.com/example-user' )
247247 . replace (
248- / g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ \ /] + / g,
248+ / g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ / ] + / g,
249249 'github.com/example-user/example-repo' ,
250250 )
251251 }
252252 if ( 'ssh_url' in redacted && typeof redacted . ssh_url === 'string' ) {
253253 redacted . ssh_url = redacted . ssh_url
254- . replace ( / g i t h u b \. c o m : [ ^ \ /] + / g, 'github.com:example-user' )
254+ . replace ( / g i t h u b \. c o m : [ ^ / ] + / g, 'github.com:example-user' )
255255 . replace (
256- / g i t h u b \. c o m : e x a m p l e - u s e r \/ [ ^ \ /] + / g,
256+ / g i t h u b \. c o m : e x a m p l e - u s e r \/ [ ^ / ] + / g,
257257 'github.com:example-user/example-repo' ,
258258 )
259259 }
260260 if ( 'git_url' in redacted && typeof redacted . git_url === 'string' ) {
261261 redacted . git_url = redacted . git_url
262- . replace ( / g i t h u b \. c o m \/ [ ^ \ /] + / g, 'github.com/example-user' )
262+ . replace ( / g i t h u b \. c o m \/ [ ^ / ] + / g, 'github.com/example-user' )
263263 . replace (
264- / g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ \ /] + / g,
264+ / g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ / ] + / g,
265265 'github.com/example-user/example-repo' ,
266266 )
267267 }
268268 if ( 'svn_url' in redacted && typeof redacted . svn_url === 'string' ) {
269269 redacted . svn_url = redacted . svn_url
270- . replace ( / g i t h u b \. c o m \/ [ ^ \ /] + / g, 'github.com/example-user' )
270+ . replace ( / g i t h u b \. c o m \/ [ ^ / ] + / g, 'github.com/example-user' )
271271 . replace (
272- / g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ \ /] + / g,
272+ / g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ / ] + / g,
273273 'github.com/example-user/example-repo' ,
274274 )
275275 }
@@ -284,11 +284,11 @@ const redactGitHubData = (obj: any): any => {
284284 ) {
285285 redacted . latest_comment_url = redacted . latest_comment_url
286286 . replace (
287- / a p i \. g i t h u b \. c o m \/ r e p o s \/ [ ^ \ /] + \/ [ ^ \ /] + / g,
287+ / a p i \. g i t h u b \. c o m \/ r e p o s \/ [ ^ / ] + \/ [ ^ / ] + / g,
288288 'api.github.com/repos/example-user/example-repo' ,
289289 )
290290 . replace (
291- / a p i \. g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ \ /] + \/ [ ^ \ /] + / g,
291+ / a p i \. g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ / ] + \/ [ ^ / ] + / g,
292292 'api.github.com/repos/example-user/example-repo' ,
293293 )
294294 . replace ( / \/ c o m m e n t s \/ \d + / g, '/comments/12345' )
@@ -347,31 +347,31 @@ const redactGitHubData = (obj: any): any => {
347347 if ( field in redacted && typeof redacted [ field ] === 'string' ) {
348348 redacted [ field ] = redacted [ field ]
349349 // Replace GitHub.com URLs
350- . replace ( / g i t h u b \. c o m \/ [ ^ \ /] + / g, 'github.com/example-user' )
350+ . replace ( / g i t h u b \. c o m \/ [ ^ / ] + / g, 'github.com/example-user' )
351351 // Replace API URLs - handle all patterns
352352 . replace (
353- / a p i \. g i t h u b \. c o m \/ r e p o s \/ [ ^ \ /] + \/ [ ^ \ /] + / g,
353+ / a p i \. g i t h u b \. c o m \/ r e p o s \/ [ ^ / ] + \/ [ ^ / ] + / g,
354354 'api.github.com/repos/example-user/example-repo' ,
355355 )
356356 . replace (
357- / a p i \. g i t h u b \. c o m \/ u s e r s \/ [ ^ \ /] + / g,
357+ / a p i \. g i t h u b \. c o m \/ u s e r s \/ [ ^ / ] + / g,
358358 'api.github.com/users/example-user' ,
359359 )
360360 . replace (
361- / a p i \. g i t h u b \. c o m \/ o r g s \/ [ ^ \ /] + / g,
361+ / a p i \. g i t h u b \. c o m \/ o r g s \/ [ ^ / ] + / g,
362362 'api.github.com/orgs/example-org' ,
363363 )
364364 // Handle patterns where example-user is already present
365365 . replace (
366- / a p i \. g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ \ /] + \/ [ ^ \ /] + / g,
366+ / a p i \. g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ / ] + \/ [ ^ / ] + / g,
367367 'api.github.com/repos/example-user/example-repo' ,
368368 )
369369 . replace (
370- / a p i \. g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ \ /] + (? = \/ | $ ) / g,
370+ / a p i \. g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ / ] + (? = \/ | $ ) / g,
371371 'api.github.com/users/example-user' ,
372372 )
373373 . replace (
374- / g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ \ /] + / g,
374+ / g i t h u b \. c o m \/ e x a m p l e - u s e r \/ [ ^ / ] + / g,
375375 'github.com/example-user/example-repo' ,
376376 )
377377 }
@@ -393,8 +393,8 @@ const redactGitHubData = (obj: any): any => {
393393
394394 // Recursively process arrays and nested objects
395395 Object . keys ( redacted ) . forEach ( ( key ) => {
396- if ( typeof redacted [ key ] === 'object' && redacted [ key ] !== null ) {
397- redacted [ key ] = redactGitHubData ( redacted [ key ] )
396+ if ( typeof redacted [ key as keyof typeof redacted ] === 'object' && redacted [ key as keyof typeof redacted ] !== null ) {
397+ redacted [ key as keyof typeof redacted ] = redactGitHubData ( redacted [ key as keyof typeof redacted ] )
398398 }
399399 } )
400400
0 commit comments