fix: add input validation and safe JSON parsing across 13 CLIs
Add missing parameter validation to prevent /path/undefined API calls: - dub: require --url for links create - google-search-console: require --sitemap-url for sitemaps submit - kit: validate IDs and emails for subscribers, forms, sequences, tags, broadcasts - mailchimp: validate IDs for lists get, campaigns get/create/send, members add, reports get - resend: validate --from/--to/--subject for send, audience/contact IDs for contacts - rewardful: validate IDs for affiliates get/update, commissions get, links create - semrush: require --domain/--phrase for all domain and keyword commands - sendgrid: validate --from/--to/--subject for send, campaign IDs, email for validate Wrap bare JSON.parse() calls in try/catch for user-provided JSON: - dub (--links), ga4 (--params), kit (--fields x4), mixpanel (--properties x2), onesignal (--filters), paddle (--scheduled-change, --items x2), resend (--emails, --variables x2), segment (--properties, --traits, --events), sendgrid (--template-data) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+8
-1
@@ -150,7 +150,14 @@ async function main() {
|
||||
if (!args['api-secret']) { result = { error: '--api-secret required' }; break }
|
||||
if (!args['client-id']) { result = { error: '--client-id required' }; break }
|
||||
if (!args['event-name']) { result = { error: '--event-name required' }; break }
|
||||
const eventParams = args.params ? JSON.parse(args.params) : {}
|
||||
let eventParams = {}
|
||||
if (args.params) {
|
||||
try {
|
||||
eventParams = JSON.parse(args.params)
|
||||
} catch {
|
||||
result = { error: 'Invalid JSON in --params' }; break
|
||||
}
|
||||
}
|
||||
const body = {
|
||||
client_id: args['client-id'],
|
||||
events: [{
|
||||
|
||||
Reference in New Issue
Block a user