Skip to content

Commit 0de59c2

Browse files
NicelyDunn7Copilot
andauthored
Secret Scanning pattern docs refactor (#58635)
Co-authored-by: Copilot <[email protected]>
1 parent ac39da2 commit 0de59c2

File tree

10 files changed

+244
-12396
lines changed

10 files changed

+244
-12396
lines changed

src/secret-scanning/data/pattern-docs/fpt/public-docs.yml

Lines changed: 122 additions & 2222 deletions
Large diffs are not rendered by default.

src/secret-scanning/data/pattern-docs/ghec/public-docs.yml

Lines changed: 119 additions & 2232 deletions
Large diffs are not rendered by default.

src/secret-scanning/data/pattern-docs/ghes-3.14/public-docs.yml

Lines changed: 0 additions & 1221 deletions
Large diffs are not rendered by default.

src/secret-scanning/data/pattern-docs/ghes-3.15/public-docs.yml

Lines changed: 0 additions & 1084 deletions
Large diffs are not rendered by default.

src/secret-scanning/data/pattern-docs/ghes-3.16/public-docs.yml

Lines changed: 0 additions & 1219 deletions
Large diffs are not rendered by default.

src/secret-scanning/data/pattern-docs/ghes-3.17/public-docs.yml

Lines changed: 0 additions & 1303 deletions
Large diffs are not rendered by default.

src/secret-scanning/data/pattern-docs/ghes-3.18/public-docs.yml

Lines changed: 0 additions & 1404 deletions
Large diffs are not rendered by default.

src/secret-scanning/data/pattern-docs/ghes-3.19/public-docs.yml

Lines changed: 0 additions & 1690 deletions
Large diffs are not rendered by default.

src/secret-scanning/data/public-docs-schema.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
import { schema } from '@/frame/lib/frontmatter'
2-
3-
// Secret scanning entries have `versions` blocks that match `versions` frontmatter,
4-
// so we can import that part of the FM schema.
5-
// Access the versions property which is defined dynamically in frontmatter.ts
6-
const versionsProps = Object.assign({}, (schema.properties as Record<string, any>).versions)
7-
81
// The secret-scanning.json contains an array of objects that look like this:
92
// {
103
// "provider": "Azure",
114
// "supportedSecret": "Azure SQL Connection String",
125
// "secretType": "azure_sql_connection_string",
13-
// "versions": {
14-
// "fpt": "*",
15-
// "ghec": "*",
16-
// "ghes": "*"
17-
// },
186
// "isPublic": true,
197
// "isPrivateWithGhas": true,
208
// "hasPushProtection": false,
@@ -27,7 +15,6 @@ export interface SecretScanningEntry {
2715
provider: string
2816
supportedSecret: string
2917
secretType: string
30-
versions: Record<string, string>
3118
isPublic: boolean | string
3219
isPrivateWithGhas: boolean | string
3320
hasPushProtection: boolean | string
@@ -45,7 +32,6 @@ export default {
4532
'provider',
4633
'supportedSecret',
4734
'secretType',
48-
'versions',
4935
'isPublic',
5036
'isPrivateWithGhas',
5137
'hasPushProtection',
@@ -65,7 +51,6 @@ export default {
6551
type: 'string',
6652
pattern: '[A-Za-z0-9_-]',
6753
},
68-
versions: versionsProps,
6954
isPublic: {
7055
description: 'whether the secret is publicly available',
7156
type: ['boolean', 'string'],

src/secret-scanning/middleware/secret-scanning.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import fs from 'fs'
33
import yaml from 'js-yaml'
44
import type { NextFunction, Response } from 'express'
55

6-
import getApplicableVersions from '@/versions/lib/get-applicable-versions'
76
import { liquid } from '@/content-render/index'
87
import { ExtendedRequest, SecretScanningData } from '@/types'
98
import { allVersions } from '@/versions/lib/all-versions'
@@ -38,11 +37,9 @@ export default async function secretScanning(
3837
: 'fpt'
3938
const filepath = `${secretScanningDir}/${versionPath}/public-docs.yml`
4039

41-
const secretScanningData = yaml.load(fs.readFileSync(filepath, 'utf-8')) as SecretScanningData[]
42-
43-
req.context.secretScanningData = secretScanningData.filter((entry) =>
44-
currentVersion ? getApplicableVersions(entry.versions).includes(currentVersion) : false,
45-
)
40+
req.context.secretScanningData = yaml.load(
41+
fs.readFileSync(filepath, 'utf-8'),
42+
) as SecretScanningData[]
4643

4744
// Some entries might use Liquid syntax, so we need
4845
// to execute that Liquid to get the actual value.

0 commit comments

Comments
 (0)