Skip to content

Commit 75933e3

Browse files
authored
Merge branch 'main' into less_yaml
2 parents 4af79de + f60b83b commit 75933e3

File tree

63 files changed

+622
-481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+622
-481
lines changed

.config/rollup.dist.config.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ async function copyBlessedWidgets() {
107107
const blessedDestPath = path.join(rootDistPath, 'blessed')
108108
const blessedNmPath = path.join(rootPath, 'node_modules/blessed')
109109
const folders = ['lib', 'usr', 'vendor']
110-
await Promise.all([
111-
...folders.map(f =>
110+
await Promise.all(
111+
folders.map(f =>
112112
fs.cp(path.join(blessedNmPath, f), path.join(blessedDestPath, f), {
113113
recursive: true
114114
})
115115
)
116-
])
116+
)
117117
// Add 'use strict' directive to js files.
118118
const jsFiles = await tinyGlob(['**/*.js'], {
119119
absolute: true,

src/commands/analytics/cmd-analytics.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ describe('socket analytics', async () => {
2323
Usage
2424
$ socket analytics --scope=<scope> --time=<time filter>
2525
26+
API Token Requirements
27+
- Quota: 1 unit
28+
- Permissions: report:write
29+
2630
Default parameters are set to show the organization-level analytics over the
2731
last 7 days.
2832

src/commands/analytics/cmd-analytics.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ const config: CliCommandConfig = {
5252
Usage
5353
$ ${command} --scope=<scope> --time=<time filter>
5454
55+
API Token Requirements
56+
- Quota: 1 unit
57+
- Permissions: report:write
58+
5559
Default parameters are set to show the organization-level analytics over the
5660
last 7 days.
5761
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
{
2+
"results": [
3+
{
4+
"event_id": "123112",
5+
"created_at": "2025-04-02T01:47:26.914Z",
6+
"updated_at": "2025-04-02T01:47:26.914Z",
7+
"country_code": "",
8+
"organization_id": "1381",
9+
"ip_address": "",
10+
"payload": {
11+
"settingKey": "vantaViewSelector",
12+
"settingValue": {
13+
"ignoreAlerts": "",
14+
"ignoreIngress": ""
15+
}
16+
},
17+
"status_code": 0,
18+
"type": "updateOrganizationSetting",
19+
"user_agent": "",
20+
"user_id": "7d8b2478-abcd-4cc9-abcd-c869de8fc924",
21+
"user_email": "person@socket.dev",
22+
"user_image": "",
23+
"organization_name": "SocketDev"
24+
},
25+
{
26+
"event_id": "122421",
27+
"created_at": "2025-03-31T15:19:55.299Z",
28+
"updated_at": "2025-03-31T15:19:55.299Z",
29+
"country_code": "",
30+
"organization_id": "1381",
31+
"ip_address": "123.123.321.213",
32+
"payload": {
33+
"name": "zero-access",
34+
"token": "sktsec_...LZEh_api",
35+
"scopes": []
36+
},
37+
"status_code": 0,
38+
"type": "createApiToken",
39+
"user_agent": "",
40+
"user_id": "e110f7e0-abcd-41bb-abcd-5745be143db8",
41+
"user_email": "person@socket.dev",
42+
"user_image": "",
43+
"organization_name": "SocketDev"
44+
},
45+
{
46+
"event_id": "121392",
47+
"created_at": "2025-03-27T16:24:36.344Z",
48+
"updated_at": "2025-03-27T16:24:36.344Z",
49+
"country_code": "",
50+
"organization_id": "1381",
51+
"ip_address": "",
52+
"payload": {
53+
"settingKey": "sso",
54+
"settingValue": {
55+
"defaultMemberRole": "member"
56+
}
57+
},
58+
"status_code": 0,
59+
"type": "updateOrganizationSetting",
60+
"user_agent": "super ai .com",
61+
"user_id": "6dc7b702-abcd-438a-abcd-51e227962ebd",
62+
"user_email": "person@socket.dev",
63+
"user_image": "",
64+
"organization_name": "SocketDev"
65+
},
66+
{
67+
"event_id": "121391",
68+
"created_at": "2025-03-27T16:24:33.912Z",
69+
"updated_at": "2025-03-27T16:24:33.912Z",
70+
"country_code": "",
71+
"organization_id": "1381",
72+
"ip_address": "",
73+
"payload": {
74+
"settingKey": "sso",
75+
"settingValue": {
76+
"defaultMemberRole": "member",
77+
"requireSSOOnLogin": true
78+
}
79+
},
80+
"status_code": 0,
81+
"type": "updateOrganizationSetting",
82+
"user_agent": "",
83+
"user_id": "6dc7b702-abcd-438a-abcd-51e227962ebd",
84+
"user_email": "person@socket.dev",
85+
"user_image": "",
86+
"organization_name": "SocketDev"
87+
},
88+
{
89+
"event_id": "120287",
90+
"created_at": "2025-03-24T21:52:12.879Z",
91+
"updated_at": "2025-03-24T21:52:12.879Z",
92+
"country_code": "",
93+
"organization_id": "1381",
94+
"ip_address": "",
95+
"payload": {
96+
"alertKey": "Q2URU2WWK6G4jQd3ReRfK-ZUo4xkF_CffmpkhbfgOd3c",
97+
"alertTriageNote": "",
98+
"alertTriageState": null
99+
},
100+
"status_code": 0,
101+
"type": "updateAlertTriage",
102+
"user_agent": "",
103+
"user_id": "b5d98911-abcd-425b-abcd-c71534f0ef88",
104+
"user_email": "person@socket.dev",
105+
"user_image": "",
106+
"organization_name": "SocketDev"
107+
},
108+
{
109+
"event_id": "118431",
110+
"created_at": "2025-03-17T15:57:29.885Z",
111+
"updated_at": "2025-03-17T15:57:29.885Z",
112+
"country_code": "",
113+
"organization_id": "1381",
114+
"ip_address": "",
115+
"payload": {
116+
"settingKey": "licensePolicy",
117+
"settingValue": {
118+
"allow": {
119+
"strings": ["0BSD", "ADSL", "AFL-1.1"]
120+
},
121+
"options": {
122+
"strings": ["toplevelOnly"]
123+
}
124+
}
125+
},
126+
"status_code": 0,
127+
"type": "updateOrganizationSetting",
128+
"user_agent": "",
129+
"user_id": "7d8b2478-abcd-4cc9-abcd-c869de8fc924",
130+
"user_email": "person@socket.dev",
131+
"user_image": "",
132+
"organization_name": "SocketDev"
133+
},
134+
{
135+
"event_id": "116928",
136+
"created_at": "2025-03-10T22:53:35.734Z",
137+
"updated_at": "2025-03-10T22:53:35.734Z",
138+
"country_code": "",
139+
"organization_id": "1381",
140+
"ip_address": "",
141+
"payload": {
142+
"token": "sktsec_...wnTa_api",
143+
"scopes": [
144+
"report",
145+
"repo",
146+
"full-scans",
147+
"packages",
148+
"audit-log",
149+
"integration",
150+
"threat-feed",
151+
"security-policy",
152+
"alerts",
153+
"dependencies",
154+
"historical"
155+
],
156+
"oldScopes": [
157+
"report",
158+
"repo",
159+
"full-scans",
160+
"packages",
161+
"audit-log",
162+
"integration",
163+
"threat-feed",
164+
"security-policy",
165+
"alerts",
166+
"dependencies",
167+
"historical"
168+
]
169+
},
170+
"status_code": 0,
171+
"type": "updateApiTokenScopes",
172+
"user_agent": "",
173+
"user_id": "1fc4346e-abcd-4537-abcd-113e0e9609b5",
174+
"user_email": "person@socket.dev",
175+
"user_image": "",
176+
"organization_name": "SocketDev"
177+
}
178+
],
179+
"nextPage": "2"
180+
}

src/commands/audit-log/cmd-audit-log.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ describe('socket audit-log', async () => {
2323
Usage
2424
$ socket audit-log <org slug>
2525
26+
API Token Requirements
27+
- Quota: 1 unit
28+
- Permissions: audit-log:list
29+
2630
This feature requires an Enterprise Plan. To learn more about getting access
2731
to this feature and many more, please visit https://socket.dev/pricing
2832

src/commands/audit-log/cmd-audit-log.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ const config: CliCommandConfig = {
4343
Usage
4444
$ ${command} <org slug>
4545
46+
API Token Requirements
47+
- Quota: 1 unit
48+
- Permissions: audit-log:list
49+
4650
This feature requires an Enterprise Plan. To learn more about getting access
4751
to this feature and many more, please visit https://socket.dev/pricing
4852
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
import { describe, expect, it } from 'vitest'
2+
3+
import FIXTURE from './audit-fixture.json' with { type: 'json' }
4+
import { outputAsJson, outputAsMarkdown } from './output-audit-log'
5+
6+
describe('output-audit-log', () => {
7+
describe('json', () => {
8+
it('should return formatted json string', async () => {
9+
const r = await outputAsJson(
10+
JSON.parse(JSON.stringify(FIXTURE.results)),
11+
{
12+
logType: '',
13+
orgSlug: 'noorgslug',
14+
page: 1,
15+
perPage: 10
16+
}
17+
)
18+
expect(r).toMatchInlineSnapshot(`
19+
"{
20+
"desc": "Audit logs for given query",
21+
"generated": "<redacted>",
22+
"org": "noorgslug",
23+
"logType": "",
24+
"page": 1,
25+
"perPage": 10,
26+
"logs": [
27+
{
28+
"event_id": "123112",
29+
"created_at": "2025-04-02T01:47:26.914Z",
30+
"ip_address": "",
31+
"type": "updateOrganizationSetting",
32+
"user_agent": "",
33+
"user_email": "person@socket.dev"
34+
},
35+
{
36+
"event_id": "122421",
37+
"created_at": "2025-03-31T15:19:55.299Z",
38+
"ip_address": "123.123.321.213",
39+
"type": "createApiToken",
40+
"user_agent": "",
41+
"user_email": "person@socket.dev"
42+
},
43+
{
44+
"event_id": "121392",
45+
"created_at": "2025-03-27T16:24:36.344Z",
46+
"ip_address": "",
47+
"type": "updateOrganizationSetting",
48+
"user_agent": "super ai .com",
49+
"user_email": "person@socket.dev"
50+
},
51+
{
52+
"event_id": "121391",
53+
"created_at": "2025-03-27T16:24:33.912Z",
54+
"ip_address": "",
55+
"type": "updateOrganizationSetting",
56+
"user_agent": "",
57+
"user_email": "person@socket.dev"
58+
},
59+
{
60+
"event_id": "120287",
61+
"created_at": "2025-03-24T21:52:12.879Z",
62+
"ip_address": "",
63+
"type": "updateAlertTriage",
64+
"user_agent": "",
65+
"user_email": "person@socket.dev"
66+
},
67+
{
68+
"event_id": "118431",
69+
"created_at": "2025-03-17T15:57:29.885Z",
70+
"ip_address": "",
71+
"type": "updateOrganizationSetting",
72+
"user_agent": "",
73+
"user_email": "person@socket.dev"
74+
},
75+
{
76+
"event_id": "116928",
77+
"created_at": "2025-03-10T22:53:35.734Z",
78+
"ip_address": "",
79+
"type": "updateApiTokenScopes",
80+
"user_agent": "",
81+
"user_email": "person@socket.dev"
82+
}
83+
]
84+
}"
85+
`)
86+
})
87+
88+
it('should return empty object string on error', async () => {
89+
const r = await outputAsJson(
90+
{},
91+
{
92+
logType: '',
93+
orgSlug: 'noorgslug',
94+
page: 1,
95+
perPage: 10
96+
}
97+
)
98+
expect(r).toMatchInlineSnapshot(`"{}"`)
99+
})
100+
})
101+
102+
describe('markdown', () => {
103+
it('should return markdown report', async () => {
104+
const r = await outputAsMarkdown(
105+
JSON.parse(JSON.stringify(FIXTURE.results)),
106+
{
107+
logType: '',
108+
orgSlug: 'noorgslug',
109+
page: 1,
110+
perPage: 10
111+
}
112+
)
113+
expect(r).toMatchInlineSnapshot(`
114+
"
115+
# Socket Audit Logs
116+
117+
These are the Socket.dev audit logs as per requested query.
118+
- org: noorgslug
119+
- type filter: (none)
120+
- page: 1
121+
- per page: 10
122+
- generated: <redacted>
123+
124+
| -------- | ------------------------ | ------------------------- | ----------------- | --------------- | ------------- |
125+
| event_id | created_at | type | user_email | ip_address | user_agent |
126+
| -------- | ------------------------ | ------------------------- | ----------------- | --------------- | ------------- |
127+
| 123112 | 2025-04-02T01:47:26.914Z | updateOrganizationSetting | person@socket.dev | | |
128+
| 122421 | 2025-03-31T15:19:55.299Z | createApiToken | person@socket.dev | 123.123.321.213 | |
129+
| 121392 | 2025-03-27T16:24:36.344Z | updateOrganizationSetting | person@socket.dev | | super ai .com |
130+
| 121391 | 2025-03-27T16:24:33.912Z | updateOrganizationSetting | person@socket.dev | | |
131+
| 120287 | 2025-03-24T21:52:12.879Z | updateAlertTriage | person@socket.dev | | |
132+
| 118431 | 2025-03-17T15:57:29.885Z | updateOrganizationSetting | person@socket.dev | | |
133+
| 116928 | 2025-03-10T22:53:35.734Z | updateApiTokenScopes | person@socket.dev | | |
134+
| -------- | ------------------------ | ------------------------- | ----------------- | --------------- | ------------- |
135+
"
136+
`)
137+
})
138+
139+
it('should return empty string on error', async () => {
140+
const r = await outputAsMarkdown(
141+
{},
142+
{
143+
logType: '',
144+
orgSlug: 'noorgslug',
145+
page: 1,
146+
perPage: 10
147+
}
148+
)
149+
expect(r).toMatchInlineSnapshot(`""`)
150+
})
151+
})
152+
})

0 commit comments

Comments
 (0)