Skip to content

Commit 98878a4

Browse files
authored
Merge pull request #154 from OpenPathfinder/rework-logger
Migrated to Pino with improved logger levels and initialization, added `[email protected]` and `[email protected]` as dependencies, enhanced CLI feedback messages, and improved handling of sensitive information in the logger to prevent leaks (closes #132).
2 parents b62b7f1 + dd03cbc commit 98878a4

File tree

10 files changed

+275
-39
lines changed

10 files changed

+275
-39
lines changed

__tests__/utils.test.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { validateGithubUrl, ensureGithubToken, groupArrayItemsByCriteria, isCheckApplicableToProjectCategory, getSeverityFromPriorityGroup, isDateWithinPolicy } = require('../src/utils/index')
1+
const { validateGithubUrl, ensureGithubToken, groupArrayItemsByCriteria, isCheckApplicableToProjectCategory, getSeverityFromPriorityGroup, isDateWithinPolicy, redactSensitiveData } = require('../src/utils/index')
22

33
describe('ensureGithubToken', () => {
44
let originalGithubToken
@@ -156,3 +156,15 @@ describe('isDateWithinPolicy', () => {
156156
expect(() => isDateWithinPolicy(undefined, policy)).toThrow('Target date is required')
157157
})
158158
})
159+
160+
describe('redactSensitiveData', () => {
161+
it('should redact sensitive data from a string', () => {
162+
const input = 'This has a token: ghp_234 and other information'
163+
const expected = 'This has a token: [REDACTED] and other information'
164+
expect(redactSensitiveData(input)).toBe(expected)
165+
})
166+
it('Should return the same string if no sensitive data is found', () => {
167+
const input = 'This is a normal string'
168+
expect(redactSensitiveData(input)).toBe(input)
169+
})
170+
})

index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ project
2020
try {
2121
await runAddProjectCommand(knex, options)
2222
} catch (error) {
23-
logger.error('Error adding project:', error.message)
23+
logger.error(error)
2424
process.exit(1)
2525
} finally {
2626
await knex.destroy()
@@ -38,7 +38,7 @@ workflow
3838
try {
3939
await runWorkflowCommand(knex, options)
4040
} catch (error) {
41-
logger.error('Error running workflow:', error.message)
41+
logger.error(error)
4242
process.exit(1)
4343
} finally {
4444
await knex.destroy()
@@ -62,7 +62,7 @@ check
6262
try {
6363
await listCheckCommand(knex, options)
6464
} catch (error) {
65-
logger.error('Error running check:', error.message)
65+
logger.error(error)
6666
process.exit(1)
6767
} finally {
6868
await knex.destroy()
@@ -77,7 +77,7 @@ check
7777
try {
7878
await runCheckCommand(knex, options)
7979
} catch (error) {
80-
logger.error('Error running check:', error.message)
80+
logger.error(error)
8181
process.exit(1)
8282
} finally {
8383
await knex.destroy()

package-lock.json

+199-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)