Skip to content

Commit f1daa19

Browse files
committed
Cover all public Shopify credential prefixes plus shpua_
Assisted-By: devx/044e1f3f-fe03-4f4c-8aa7-520114eab4a0
1 parent 535d0e9 commit f1daa19

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

‎.changeset/app-doctor-secret-false-positives.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'@shopify/app': patch
33
---
44

5-
App Doctor's committed-secret check now only flags recognizable secret values (e.g. `shpss_`/`shpat_` tokens), not secret-sounding variable names or placeholders.
5+
The committed-secret check in `shopify app security` now only flags recognizable secret values (e.g. `shpss_`/`shpat_` tokens), not secret-sounding variable names or placeholders.

‎packages/app/src/cli/services/app-security-engine/rules/secret-rules.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ interface SecretPattern {
2626

2727
export const SECRET_PATTERNS: SecretPattern[] = [
2828
// Shopify credentials are recognized by value prefix, never by variable or
29-
// key name: shpss_ (API secret), shpat_ (Admin API token), shpca_ and
30-
// shppa_ (custom app tokens). A secret-sounding name proves nothing —
31-
// `.env.example` files legitimately assign placeholders to
32-
// `SHOPIFY_API_SECRET`, and scoring those is how this check missed its own
33-
// static-tier bar (provable facts, near-zero FPs).
29+
// key name. A secret-sounding name proves nothing — `.env.example` files
30+
// legitimately assign placeholders to `SHOPIFY_API_SECRET`, and scoring
31+
// those is how this check missed its own static-tier bar (provable facts,
32+
// near-zero FPs). shpat_/shpca_/shppa_/shpss_ bodies are 32-char hex;
33+
// shprt_/shpsb_/shptka_/shpua_ are alphanumeric. The first seven prefixes
34+
// are already public via shopify.dev docs and published secret-scanning
35+
// rules (gitleaks, GitHub partner patterns); shpua_ marks tokens issued
36+
// while an app is still in development — the most likely to be committed.
3437
{
35-
regex: /shp(?:at|ca|pa|ss)_[a-fA-F0-9]{16,}/,
38+
regex: /shp(?:(?:at|ca|pa|ss)_[a-fA-F0-9]{16,}|(?:rt|sb|tka|ua)_[a-zA-Z0-9]{16,})/,
3639
name: 'Shopify token',
3740
wholeMatch: true,
3841
},

‎packages/app/src/cli/services/app-security-engine/tests/secret-safety.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,17 @@ describe('git status drives severity, not .gitignore text', () => {
298298
})
299299

300300
describe('committed secret classification', () => {
301+
test('detects every supported Shopify credential prefix as a bare value', () => {
302+
const prefixes = ['shpat_', 'shpca_', 'shppa_', 'shpss_', 'shprt_', 'shpsb_', 'shptka_', 'shpua_']
303+
for (const prefix of prefixes) {
304+
const token = compose(prefix, HEX32)
305+
expect(
306+
SECRET_PATTERNS.some((pattern) => pattern.regex.test(token)),
307+
`${prefix} not detected`,
308+
).toBe(true)
309+
}
310+
})
311+
301312
test('does not score template env files with placeholder values', async () => {
302313
const dir = makeApp({
303314
'.env.example': 'SHOPIFY_API_SECRET=your-secret-here\nSHOPIFY_API_KEY=your-key-here\n',

0 commit comments

Comments
 (0)