Skip to content

Commit 0fba8c9

Browse files
authored
Convert secret-scanning JavaScript files to TypeScript (#55734)
1 parent ab79adb commit 0fba8c9

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/secret-scanning/data/public-docs-schema.js renamed to src/secret-scanning/data/public-docs-schema.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { schema } from '#src/frame/lib/frontmatter.js'
22

33
// Secret scanning entries have `versions` blocks that match `versions` frontmatter,
44
// so we can import that part of the FM schema.
5-
const versionsProps = Object.assign({}, schema.properties.versions)
5+
// Access the versions property which is defined dynamically in frontmatter.js
6+
const versionsProps = Object.assign({}, (schema.properties as Record<string, any>).versions)
67

78
// The secret-scanning.json contains an array of objects that look like this:
89
// {
@@ -20,6 +21,18 @@ const versionsProps = Object.assign({}, schema.properties.versions)
2021
// "hasValidityCheck": false
2122
// },
2223

24+
export interface SecretScanningEntry {
25+
provider: string
26+
supportedSecret: string
27+
secretType: string
28+
versions: Record<string, string>
29+
isPublic: boolean | string
30+
isPrivateWithGhas: boolean | string
31+
hasPushProtection: boolean | string
32+
hasValidityCheck: boolean | string
33+
isduplicate: boolean
34+
}
35+
2336
export default {
2437
type: 'array',
2538
items: {

src/secret-scanning/scripts/sync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import core from '@actions/core'
1212
import yaml from 'js-yaml'
1313

1414
import { getContentAndData, getCommitSha } from '@/workflows/git-utils.js'
15-
import schema from '@/secret-scanning/data/public-docs-schema.js'
15+
import schema from '@/secret-scanning/data/public-docs-schema'
1616
// This is temporarily being imported until the subsequent modules
1717
// have beeen converted to TypeScript.
1818
import { validateJson } from '@/tests/lib/validate-json-schema.js'

src/secret-scanning/tests/rendering.js renamed to src/secret-scanning/tests/rendering.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ import { readFileSync } from 'fs'
33

44
import { get } from '#src/tests/helpers/e2etest.js'
55

6+
interface ConfigFile {
7+
targetFilename: string
8+
}
9+
610
describe('secret-scanning pipeline', () => {
7-
const { targetFilename } = JSON.parse(readFileSync('src/secret-scanning/lib/config.json'))
11+
const { targetFilename } = JSON.parse(
12+
readFileSync('src/secret-scanning/lib/config.json', 'utf8'),
13+
) as ConfigFile
814
// This test ensures that the configured page exists. If the page moves
915
// this test will fail.
1016
test(`check if ${targetFilename} was moved`, async () => {

0 commit comments

Comments
 (0)