@dataparade/cli 0.0.23 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataparade/cli",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "dataPARADE CLI — scan codebases for privacy and security data flows",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -20,7 +20,10 @@ const HTTP_TRANSPORT_NAMES = new Set([
20
20
  'crossfetch',
21
21
  ]);
22
22
  function compactName(value) {
23
- return value.trim().toLowerCase().replace(/[\s_-]+/g, '');
23
+ return value
24
+ .trim()
25
+ .toLowerCase()
26
+ .replace(/[\s_-]+/g, '');
24
27
  }
25
28
  function isMainApplication(component) {
26
29
  const flag = component.properties?.isMainApplication;
@@ -59,7 +62,8 @@ function isNestServiceClassNode(component, readSource) {
59
62
  if (locations.length === 0)
60
63
  return false;
61
64
  const patterns = (component.detectedFrom ?? []).map((ref) => ref.pattern);
62
- if (patterns.length === 0 || patterns.some((pattern) => pattern !== 'auth_middleware')) {
65
+ if (patterns.length === 0 ||
66
+ patterns.some((pattern) => pattern !== 'auth_middleware')) {
63
67
  return false;
64
68
  }
65
69
  if (isDirectusItemsService(component, readSource))
@@ -82,7 +86,8 @@ function stringProp(component, key) {
82
86
  return typeof value === 'string' ? value : '';
83
87
  }
84
88
  function hasPublicUrl(component) {
85
- const url = stringProp(component, 'url') || (/^https?:\/\//i.test(component.name) ? component.name : '');
89
+ const url = stringProp(component, 'url') ||
90
+ (/^https?:\/\//i.test(component.name) ? component.name : '');
86
91
  if (!/^https?:\/\//i.test(url))
87
92
  return false;
88
93
  if (/\$\{|process\.env|localhost|127\.0\.0\.1/i.test(url))
@@ -114,8 +119,9 @@ function hubIdFor(components, dropped, dropIds) {
114
119
  function omitInternalImplementationNodes(components, flows, options = {}) {
115
120
  const readSource = options.readSource ?? (() => undefined);
116
121
  const dropIds = new Set(components
117
- .filter((component) => isNestServiceClassNode(component, readSource) ||
118
- isBareHttpTransportNode(component))
122
+ .filter((component) => !isMainApplication(component) &&
123
+ (isNestServiceClassNode(component, readSource) ||
124
+ isBareHttpTransportNode(component)))
119
125
  .map((component) => component.id));
120
126
  if (dropIds.size === 0) {
121
127
  return { components, dataFlows: flows };
@@ -69,7 +69,11 @@ describe('omitInternalImplementationNodes', () => {
69
69
  id: 'sendgrid',
70
70
  name: 'Sendgrid',
71
71
  type: 'third_party',
72
- properties: { serviceName: 'sendgrid', client: 'axios', section_id: 'backend' },
72
+ properties: {
73
+ serviceName: 'sendgrid',
74
+ client: 'axios',
75
+ section_id: 'backend',
76
+ },
73
77
  },
74
78
  ], [
75
79
  {
@@ -97,16 +101,62 @@ describe('omitInternalImplementationNodes', () => {
97
101
  type: 'api_call',
98
102
  },
99
103
  ], { readSource });
100
- expect(result.components.map((component) => component.name).sort()).toEqual([
101
- 'Sendgrid',
102
- 'Users',
103
- 'backend',
104
- ]);
105
- expect(result.dataFlows.map((flow) => [flow.sourceComponentId, flow.targetComponentId])).toEqual([
104
+ expect(result.components.map((component) => component.name).sort()).toEqual(['Sendgrid', 'Users', 'backend']);
105
+ expect(result.dataFlows.map((flow) => [
106
+ flow.sourceComponentId,
107
+ flow.targetComponentId,
108
+ ])).toEqual([
106
109
  ['hub', 'users'],
107
110
  ['hub', 'sendgrid'],
108
111
  ]);
109
112
  });
113
+ it('keeps section hubs that were promoted from a service class or an HTTP call', () => {
114
+ const result = (0, omit_internal_implementation_1.omitInternalImplementationNodes)([
115
+ {
116
+ id: 'backend',
117
+ name: 'backend',
118
+ type: 'asset',
119
+ subType: 'service',
120
+ detectedFrom: [{ pattern: 'auth_middleware' }],
121
+ sourceLocations: [
122
+ {
123
+ filePath: 'backend/src/diagrams/services/asset-context.service.ts',
124
+ startLine: 5,
125
+ },
126
+ ],
127
+ properties: { isMainApplication: true, section_id: 'backend' },
128
+ },
129
+ {
130
+ id: 'lambdas',
131
+ name: 'lambdas',
132
+ type: 'asset',
133
+ subType: 'api',
134
+ properties: {
135
+ isMainApplication: 'true',
136
+ client: 'axios',
137
+ section_id: 'backend/lambdas',
138
+ },
139
+ },
140
+ {
141
+ id: 'customer',
142
+ name: 'Customer',
143
+ type: 'actor',
144
+ properties: { section_id: 'backend' },
145
+ },
146
+ ], [
147
+ {
148
+ sourceComponentId: 'customer',
149
+ targetComponentId: 'backend',
150
+ type: 'user_interaction',
151
+ },
152
+ ], { readSource });
153
+ expect(result.components.map((component) => component.id)).toEqual([
154
+ 'backend',
155
+ 'lambdas',
156
+ 'customer',
157
+ ]);
158
+ expect(result.dataFlows).toHaveLength(1);
159
+ });
110
160
  it('keeps a service class when its source file cannot be read', () => {
111
161
  const result = (0, omit_internal_implementation_1.omitInternalImplementationNodes)([
112
162
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataparade/cli",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "dataPARADE CLI — scan codebases for privacy and security data flows",
5
5
  "publishConfig": {
6
6
  "access": "public",