Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22382,6 +22382,10 @@ var EVIDENCE_REGISTRY = [
rule("SG-SCOPE-001", "metaobjects", ["read_metaobjects"], "https://shopify.dev/docs/api/admin-graphql/2026-10/queries/metaobjects", "App-owned metaobjects may have special access behavior; this rule is intentionally conservative for merchant-owned access."),
rule("SG-SCOPE-001", "metaobject", ["read_metaobjects"], "https://shopify.dev/docs/api/admin-graphql/2026-10/queries/metaobject", "App-owned metaobjects may have special access behavior; this rule is intentionally conservative for merchant-owned access."),
rule("SG-SCOPE-001", "cartTransformCreate", ["write_cart_transforms"], "https://shopify.dev/docs/api/admin-graphql/2026-10/mutations/carttransformcreate"),
rule("SG-SCOPE-001", "discountNode", ["read_discounts"], "https://shopify.dev/docs/api/admin-graphql/2026-10/queries/discountNode"),
rule("SG-SCOPE-001", "discountNode.discount.rollouts", ["read_rollouts"], "https://shopify.dev/docs/api/usage/access-scopes", "Discount.rollouts is available in Admin GraphQL 2026-10+. Reading the discount itself still requires its resource scope, such as read_discounts.", "2026-10"),
rule("SG-SCOPE-001", "discountNodes", ["read_discounts"], "https://shopify.dev/docs/api/admin-graphql/2026-10/queries/discountNodes"),
rule("SG-SCOPE-001", "discountNodes.nodes.discount.rollouts", ["read_rollouts"], "https://shopify.dev/docs/api/usage/access-scopes", "Discount.rollouts is available in Admin GraphQL 2026-10+. Reading the discount itself still requires its resource scope, such as read_discounts.", "2026-10"),
rule("SG-SCOPE-001", "analyticsAnnotationCreate", ["write_analytics_annotations"], "https://shopify.dev/docs/api/admin-graphql/2026-10/mutations/analyticsannotationcreate", "", "2026-10"),
rule("SG-SCOPE-001", "analyticsAnnotationUpdate", ["write_analytics_annotations"], "https://shopify.dev/docs/api/admin-graphql/2026-10/mutations/analyticsannotationupdate", "", "2026-10"),
rule("SG-SCOPE-001", "analyticsAnnotationDelete", ["write_analytics_annotations"], "https://shopify.dev/docs/api/admin-graphql/2026-10/mutations/analyticsannotationdelete", "", "2026-10"),
Expand Down
4 changes: 4 additions & 0 deletions src/evidence/registry.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 26 additions & 1 deletion test/analyzer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@ test('2026-10 evidence maps analytics, reports, and rollouts', () => {
assert.ok(r.observations.some(item => item.operation === 'analyticsTargets'));
assert.ok(r.observations.some(item => item.operation === 'rollouts'));
});
test('discount rollouts nested under discountNode require read_rollouts', t => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'scope-discount-rollouts-'));
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
fs.writeFileSync(path.join(root, 'shopify.app.toml'), '[access_scopes]\nscopes="read_discounts"');
fs.writeFileSync(path.join(root, 'discount.graphql'), `query DiscountRollouts {
discountNode(id: "gid://shopify/DiscountNode/1") {
discount { ...RolloutFields }
}
}
fragment RolloutFields on DiscountCodeBasic {
rolloutInfo: rollouts(first: 1) { nodes { id } }
}`);
const report = audit({ root });
assert.ok(report.observations.some(item => item.operation === 'discountNode.discount.rollouts' && item.scope.includes('read_rollouts')));
assert.ok(report.findings.some(item => item.ruleId === 'SG-SCOPE-001' && item.scope === 'read_rollouts'));
assert.equal(report.unknown.length, 0);
fs.writeFileSync(path.join(root, 'shopify.app.toml'), '[access_scopes]\nscopes="read_discounts,read_rollouts"');
assert.equal(audit({ root }).findings.some(item => item.ruleId === 'SG-SCOPE-001'), false);
});
test('json output is stable and parseable', () => { const json = toJson(audit({ root: fixture('02-missing-scope') })); assert.equal(JSON.parse(json).tool.name, 'shopify-scope-guard'); });
test('sarif output is 2.1.0', () => assert.equal(JSON.parse(toSarif(audit({ root: fixture('02-missing-scope') }))).version, '2.1.0'));
import fs from 'node:fs';
Expand All @@ -44,7 +63,13 @@ for (const rule of EVIDENCE_REGISTRY) {
const report=audit({root});
assert.ok(report.observations.some(o=>o.operation===rule.operation));
assert.ok(report.findings.some(f=>f.scope===rule.requires.anyOf[0]&&f.ruleId==='SG-SCOPE-001'));
fs.writeFileSync(path.join(root,'shopify.app.toml'),`[access_scopes]\nscopes="${rule.requires.anyOf[0]}"`);
const requiredScopes = new Set();
let prefix = '';
for (const part of rule.operation.split('.')) {
prefix = prefix ? `${prefix}.${part}` : part;
for (const ancestor of EVIDENCE_REGISTRY.filter(item => item.operation === prefix && item.operationType === rule.operationType)) requiredScopes.add(ancestor.requires.anyOf[0]);
}
fs.writeFileSync(path.join(root,'shopify.app.toml'),`[access_scopes]\nscopes="${[...requiredScopes].join(',')}"`);
assert.ok(!audit({root}).findings.some(f=>f.ruleId==='SG-SCOPE-001'));
});
}
Loading