Skip to content

Commit 7fdf33f

Browse files
authored
chore(kbn-failed-test-reporter): use a safer hashing algorithm (elastic#262734)
1 parent 99311c0 commit 7fdf33f

4 files changed

Lines changed: 2 additions & 21 deletions

File tree

packages/kbn-eslint-plugin-eslint/rules/no_unsafe_hash.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ const ALLOWED_UNSAFE_HASHES = [
2727
path: 'src/platform/packages/shared/kbn-babel-register/cache/lmdb_cache.js',
2828
algorithms: ['sha1'],
2929
},
30-
{
31-
path: 'packages/kbn-failed-test-reporter-cli/failed_tests_reporter/report_failures_to_file.ts',
32-
algorithms: ['md5'],
33-
},
34-
{
35-
path: 'packages/kbn-failed-test-reporter-cli/failed_tests_reporter/generate_scout_test_failure_artifacts.ts',
36-
algorithms: ['md5'],
37-
},
3830
];
3931

4032
const allowedAlgorithms = ['sha256', 'sha3-256', 'sha512'];

packages/kbn-eslint-plugin-eslint/rules/no_unsafe_hash.test.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,6 @@ ruleTester.run('@kbn/eslint/no_unsafe_hash', rule, {
6969
`,
7070
filename: path.resolve(KIBANA_ROOT, 'packages/kbn-optimizer/src/common/dll_manifest.ts'),
7171
},
72-
// valid: md5 in a file that has an allowlist entry for md5
73-
{
74-
code: dedent`
75-
import { createHash } from 'crypto';
76-
createHash('md5');
77-
`,
78-
filename: path.resolve(
79-
KIBANA_ROOT,
80-
'packages/kbn-failed-test-reporter-cli/failed_tests_reporter/report_failures_to_file.ts'
81-
),
82-
},
8372
],
8473

8574
invalid: [

packages/kbn-failed-test-reporter-cli/failed_tests_reporter/generate_scout_test_failure_artifacts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function generateScoutTestFailureArtifacts({
5454
const htmlFilePath = Path.join(dirPath, htmlReportFilename);
5555
const failureHTML = fs.readFileSync(htmlFilePath, 'utf-8');
5656

57-
const hash = createHash('md5').update(name).digest('hex');
57+
const hash = createHash('sha256').update(name).digest('hex');
5858
const filenameBase = `${
5959
process.env.BUILDKITE_JOB_ID ? process.env.BUILDKITE_JOB_ID + '_' : ''
6060
}${hash}`;

packages/kbn-failed-test-reporter-cli/failed_tests_reporter/report_failures_to_file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export async function reportFailuresToFile(
127127
// Jest could, in theory, fail 1000s of tests and write 1000s of failures
128128
// So let's just write files for the first 20
129129
for (const failure of failures.slice(0, 20)) {
130-
const hash = createHash('md5').update(failure.name).digest('hex');
130+
const hash = createHash('sha256').update(failure.name).digest('hex');
131131
const filenameBase = `${
132132
process.env.BUILDKITE_JOB_ID ? process.env.BUILDKITE_JOB_ID + '_' : ''
133133
}${hash}`;

0 commit comments

Comments
 (0)