@heroku/skynet 1.6.2 → 1.6.4
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/README.md +1 -1
- package/commands/categories/add.js +21 -0
- package/commands/categories/remove.js +20 -0
- package/commands/suspend/app-owner.js +3 -2
- package/commands/suspend/user.js +3 -2
- package/index.js +2 -0
- package/lib/skynet.js +41 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ heroku plugins:install heroku-skynet-cli
|
|
|
16
16
|
### Manual testing
|
|
17
17
|
|
|
18
18
|
1. Make sure your staging account is setup: https://github.com/heroku/engineering-docs/blob/master/guides/staging-account-setup.md
|
|
19
|
-
1. Get someone to add you to the `heroku-security` team/org in staging.
|
|
19
|
+
1. Get someone to add you to the `heroku-security` team/org in [staging](https://dashboard-api-staging.herokuapp.com/teams/heroku-security/access)
|
|
20
20
|
1. Make sure you have the latest ion-client installed:
|
|
21
21
|
|
|
22
22
|
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
let cli = require('heroku-cli-util')
|
|
2
|
+
let command = require('../../lib/command')
|
|
3
|
+
let SkynetAPI = require('../../lib/skynet')
|
|
4
|
+
|
|
5
|
+
async function run (context) {
|
|
6
|
+
const skynet = new SkynetAPI(context.auth.password)
|
|
7
|
+
await cli.action(`adding new category: ${cli.color.cyan(context.flags.category)}`, skynet.addCategory(context.flags.category, context.flags.description))
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
topic: 'skynet',
|
|
12
|
+
command: 'categories:add',
|
|
13
|
+
description: 'adds a value to suspension categories',
|
|
14
|
+
help: `Examples:
|
|
15
|
+
$ heroku sudo skynet:categories:add -c new-category -d "this is a new category"`,
|
|
16
|
+
flags: [
|
|
17
|
+
{ name: 'category', char: 'c', description: 'new category value', hasValue: true, required: true },
|
|
18
|
+
{ name: 'description', char: 'd', description: 'new category description', hasValue: true, required: true }
|
|
19
|
+
],
|
|
20
|
+
run: command(run)
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
let cli = require('heroku-cli-util')
|
|
2
|
+
let command = require('../../lib/command')
|
|
3
|
+
let SkynetAPI = require('../../lib/skynet')
|
|
4
|
+
|
|
5
|
+
async function run (context) {
|
|
6
|
+
const skynet = new SkynetAPI(context.auth.password)
|
|
7
|
+
await cli.action(`removing ${cli.color.cyan(context.flags.category)} from suspension categories`, skynet.removeCategory(context.flags.category))
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
topic: 'skynet',
|
|
12
|
+
command: 'categories:remove',
|
|
13
|
+
description: 'removes a value from suspension categories',
|
|
14
|
+
help: `Examples:
|
|
15
|
+
$ heroku sudo skynet:categories:remove -c test-category`,
|
|
16
|
+
flags: [
|
|
17
|
+
{ name: 'category', char: 'c', description: 'category to remove', hasValue: true, required: true }
|
|
18
|
+
],
|
|
19
|
+
run: command(run)
|
|
20
|
+
}
|
|
@@ -41,13 +41,14 @@ async function run (context) {
|
|
|
41
41
|
|
|
42
42
|
if (file) {
|
|
43
43
|
let apps = await readlines(file)
|
|
44
|
-
|
|
44
|
+
let response = await skynet.bulkSuspendAppOwner(apps.join(), notes, category)
|
|
45
|
+
cli.log(response)
|
|
45
46
|
} else {
|
|
46
47
|
if (!app) {
|
|
47
48
|
throw new Error('Required flag: --owner OWNER or --infile FILE')
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
let response = await
|
|
51
|
+
let response = await skynet.suspendAppOwner(app, notes, category, force)
|
|
51
52
|
response = JSON.parse(response)
|
|
52
53
|
cli.log(`${response.status}. ${response.message}`)
|
|
53
54
|
}
|
package/commands/suspend/user.js
CHANGED
|
@@ -42,13 +42,14 @@ async function run (context) {
|
|
|
42
42
|
|
|
43
43
|
if (file) {
|
|
44
44
|
let users = await readlines(file)
|
|
45
|
-
|
|
45
|
+
let response = await skynet.bulkSuspendUsers(users.join(), notes, category)
|
|
46
|
+
cli.log(response)
|
|
46
47
|
} else {
|
|
47
48
|
if (!user) {
|
|
48
49
|
throw new Error('Required flag: --user USER or --infile FILE')
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
let response = await
|
|
52
|
+
let response = await skynet.suspendUser(user, notes, category, notify, force)
|
|
52
53
|
response = JSON.parse(response)
|
|
53
54
|
cli.log(`${response.status}. ${response.message}`)
|
|
54
55
|
}
|
package/index.js
CHANGED
|
@@ -14,6 +14,8 @@ exports.commands = [
|
|
|
14
14
|
require('./commands/unsuspend/user.js'),
|
|
15
15
|
require('./commands/deprovision.js'),
|
|
16
16
|
require('./commands/categories.js'),
|
|
17
|
+
require('./commands/categories/add.js'),
|
|
18
|
+
require('./commands/categories/remove.js'),
|
|
17
19
|
require('./commands/whitelist/add.js'),
|
|
18
20
|
require('./commands/whitelist/remove.js')
|
|
19
21
|
]
|
package/lib/skynet.js
CHANGED
|
@@ -21,12 +21,10 @@ module.exports = class SkynetAPI {
|
|
|
21
21
|
'User-Agent': this.version
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
if (
|
|
25
|
-
options.headers['Content-
|
|
24
|
+
if (options.form) {
|
|
25
|
+
options.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
options.json = false
|
|
29
|
-
|
|
30
28
|
return cli.got(SKYNET_BASE_URL + url, options).then(res => res.body)
|
|
31
29
|
}
|
|
32
30
|
|
|
@@ -44,7 +42,8 @@ module.exports = class SkynetAPI {
|
|
|
44
42
|
|
|
45
43
|
return this.request(`/whitelist`, {
|
|
46
44
|
method: 'POST',
|
|
47
|
-
body: qs.stringify(body)
|
|
45
|
+
body: qs.stringify(body),
|
|
46
|
+
form: true
|
|
48
47
|
})
|
|
49
48
|
}
|
|
50
49
|
|
|
@@ -62,7 +61,8 @@ module.exports = class SkynetAPI {
|
|
|
62
61
|
|
|
63
62
|
return this.request(`/userpass/remove`, {
|
|
64
63
|
method: 'POST',
|
|
65
|
-
body: qs.stringify(body)
|
|
64
|
+
body: qs.stringify(body),
|
|
65
|
+
form: true
|
|
66
66
|
})
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -74,7 +74,8 @@ module.exports = class SkynetAPI {
|
|
|
74
74
|
|
|
75
75
|
return this.request(`/userpass/add`, {
|
|
76
76
|
method: 'POST',
|
|
77
|
-
body: qs.stringify(body)
|
|
77
|
+
body: qs.stringify(body),
|
|
78
|
+
form: true
|
|
78
79
|
})
|
|
79
80
|
}
|
|
80
81
|
|
|
@@ -89,7 +90,8 @@ module.exports = class SkynetAPI {
|
|
|
89
90
|
|
|
90
91
|
return this.request('/suspend/app-owner', {
|
|
91
92
|
method: 'POST',
|
|
92
|
-
body: qs.stringify(body)
|
|
93
|
+
body: qs.stringify(body),
|
|
94
|
+
form: true
|
|
93
95
|
})
|
|
94
96
|
}
|
|
95
97
|
|
|
@@ -104,7 +106,8 @@ module.exports = class SkynetAPI {
|
|
|
104
106
|
|
|
105
107
|
return this.request('/suspend/app', {
|
|
106
108
|
method: 'POST',
|
|
107
|
-
body: qs.stringify(body)
|
|
109
|
+
body: qs.stringify(body),
|
|
110
|
+
form: true
|
|
108
111
|
})
|
|
109
112
|
}
|
|
110
113
|
|
|
@@ -126,7 +129,8 @@ module.exports = class SkynetAPI {
|
|
|
126
129
|
|
|
127
130
|
return this.request(`/suspend/user`, {
|
|
128
131
|
method: 'POST',
|
|
129
|
-
body: qs.stringify(body)
|
|
132
|
+
body: qs.stringify(body),
|
|
133
|
+
form: true
|
|
130
134
|
})
|
|
131
135
|
}
|
|
132
136
|
|
|
@@ -147,7 +151,8 @@ module.exports = class SkynetAPI {
|
|
|
147
151
|
|
|
148
152
|
return this.request(`/suspend/user`, {
|
|
149
153
|
method: 'POST',
|
|
150
|
-
body: qs.stringify(body)
|
|
154
|
+
body: qs.stringify(body),
|
|
155
|
+
form: true
|
|
151
156
|
})
|
|
152
157
|
}
|
|
153
158
|
|
|
@@ -162,7 +167,8 @@ module.exports = class SkynetAPI {
|
|
|
162
167
|
|
|
163
168
|
return this.request(`/suspend/app-owner`, {
|
|
164
169
|
method: 'POST',
|
|
165
|
-
body: qs.stringify(body)
|
|
170
|
+
body: qs.stringify(body),
|
|
171
|
+
form: true
|
|
166
172
|
})
|
|
167
173
|
}
|
|
168
174
|
|
|
@@ -177,7 +183,8 @@ module.exports = class SkynetAPI {
|
|
|
177
183
|
|
|
178
184
|
return this.request(`/deprovision`, {
|
|
179
185
|
method: 'POST',
|
|
180
|
-
body: qs.stringify(body)
|
|
186
|
+
body: qs.stringify(body),
|
|
187
|
+
form: true
|
|
181
188
|
})
|
|
182
189
|
}
|
|
183
190
|
|
|
@@ -192,7 +199,27 @@ module.exports = class SkynetAPI {
|
|
|
192
199
|
|
|
193
200
|
return this.request(`/deprovision`, {
|
|
194
201
|
method: 'POST',
|
|
195
|
-
body: qs.stringify(body)
|
|
202
|
+
body: qs.stringify(body),
|
|
203
|
+
form: true
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
addCategory (category, description) {
|
|
208
|
+
let body = {
|
|
209
|
+
category: category,
|
|
210
|
+
description: description
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return this.request(`/categories`, {
|
|
214
|
+
method: 'POST',
|
|
215
|
+
body: JSON.stringify(body),
|
|
216
|
+
json: true
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
removeCategory (category) {
|
|
221
|
+
return this.request(`/categories/${category}`, {
|
|
222
|
+
method: 'DELETE'
|
|
196
223
|
})
|
|
197
224
|
}
|
|
198
225
|
}
|