├── templates ├── action.json ├── evalMode.json ├── versionNotes.json ├── upgrade.json ├── apipiilearning.json ├── evasivepathmatch.json ├── httpheaderlogging.json ├── securitypolicyhttpheaderlogging.json ├── rename-config.json ├── recommendation.json ├── malwarepolicy-action.json ├── penalty-box.json ├── ratepolicy-action.json ├── penalty-box-conditions.json ├── eval-penalty-box-conditions.json ├── account-protection-rule-sequence.json ├── reputationanalysis.json ├── apimatchtarget.json ├── protection.json ├── matchtarget.json ├── account-protection-rule.json ├── activation.json └── pragma-header.json ├── .npmrc ├── cli.json ├── mock ├── configs │ ├── 1234 │ │ ├── versions │ │ │ ├── 1 │ │ │ │ ├── selected-hostnames.json │ │ │ │ └── activations │ │ │ │ │ └── 1.json │ │ │ ├── 2 │ │ │ │ └── selected-hostnames.json │ │ │ └── 3 │ │ │ │ └── selected-hostnames.json │ │ └── custom-rules.json │ └── 1234.json ├── configs.json ├── activations.json └── activations │ └── status │ └── f81c92c5-b150-4c41-9b53-9cef7969150a.json ├── .eslintrc.json ├── src ├── activationhistory.js ├── responseactions.js ├── contractgroups.js ├── export.js ├── accountprotectionriskactions.js ├── botanalyticscookievalues.js ├── botanalyticscookierotatevalues.js ├── botdetection.js ├── akamaidefinedbot.js ├── akamaibotcategory.js ├── clone.js ├── versionnotes.js ├── mode.js ├── apiendpoints.js ├── botendpointcoveragereport.js ├── googlerecaptchasecretkey.js ├── botanalyticscookie.js ├── botmanagementsettings.js ├── clientsidesecurity.js ├── botprotectionexceptions.js ├── customclientsequence.js ├── javascriptinjectionrules.js ├── threatintel.js ├── challengeinjectionrules.js ├── custombotcategorysequence.js ├── contentprotectionrulesequence.js ├── accountprotectionpolicysettings.js ├── accountProtectionRuleSequence.js ├── transactionalendpointprotection.js ├── bypassnl.js ├── custombotcategoryitemsequence.js ├── botdetectionaction.js ├── akamaibotcategoryaction.js ├── custombotcategoryaction.js ├── hostnamecoverage.js ├── ipgeofirewall.js ├── siemsettings.js └── policyprotection.js ├── bin └── commands │ ├── customrule.template.js │ ├── siem.js │ ├── contentprotectiondetections.js │ ├── botanalyticscookievalues.js │ ├── botendpointcoveragereport.js │ ├── config.delete.js │ ├── rotatebotanalyticscookievalues.js │ ├── botdetection.js │ ├── contracts-groups.js │ ├── akamaidefinedbot.js │ ├── botdetectionlist.js │ ├── akamaibotcategory.js │ ├── akamaidefinedbotlist.js │ ├── akamaibotcategorylist.js │ ├── customrules.js │ ├── config.clone.js │ ├── config.create.js │ ├── hosts.failover.js │ ├── customrule.delete.js │ ├── export.js │ ├── customrule.create.js │ ├── siemsettings.js │ ├── activationhistory.js │ ├── versionnotes.js │ ├── version.delete.js │ ├── botanalyticscookie.js │ ├── clientsidesecurity.js │ ├── customclientsequence.js │ ├── matchtarget.delete.js │ ├── challengeinjectionrules.js │ ├── clone.js │ ├── configs.js │ ├── customrule.modify.js │ ├── config.rename.js │ ├── custombotcategorysequence.js │ ├── customrule.js │ ├── policies.js │ ├── customdeny.delete.js │ ├── customdeny.js │ ├── accountprotectionriskactions.js │ ├── apipiilearning.js │ ├── customclient.delete.js │ ├── customclient.js │ ├── challengeaction.js │ ├── apipiilearning.enable.js │ ├── challengeaction.delete.js │ ├── accountprotectionuserallowlistid.js │ ├── apipiilearning.disable.js │ ├── ratepolicies.js │ ├── customdenyaction.js │ ├── transactionalendpointprotection.js │ ├── customdenyaction.delete.js │ ├── mode.js │ ├── conditionalaction.delete.js │ ├── conditionalaction.js │ ├── accountprotectionuserallowlistid.delete.js │ ├── versionnotes.modify.js │ ├── custombotcategory.delete.js │ ├── custombotcategory.js │ ├── customclientlist.js │ ├── botendpointcoveragereportconfigversion.js │ ├── ratepolicy.delete.js │ ├── mode.set.js │ ├── customdefinedbot.js │ ├── customdefinedbot.delete.js │ ├── customdefinedbotlist.js │ ├── servealternateaction.delete.js │ ├── servealternateaction.js │ ├── slowpost.js │ ├── challengeactionlist.js │ ├── malwarepolicies.js │ ├── responseactionslist.js │ ├── rule.upgradedetails.js │ ├── eval.stop.js │ ├── customdenyactionlist.js │ ├── accountprotectionuserriskresponsestrategy.js │ ├── custombotcategorylist.js │ ├── reputationProfiles.js │ ├── conditionalactionlist.js │ ├── eval.restart.js │ ├── eval.update.js │ ├── slowpost.disable.js │ ├── threatintel.js │ ├── penaltybox.js │ ├── securitypolicy.delete.js │ ├── eval.complete.js │ ├── securitypolicy.js │ ├── evalgroups.js │ ├── pragmaheader.js │ ├── requestbody.js │ ├── penaltybox.disable.js │ ├── malwarepolicy.delete.js │ ├── rules.js │ ├── malwarepolicycontenttypes.js │ ├── servealternateactionlist.js │ ├── threatintel.disable.js │ ├── threatintel.enable.js │ ├── version.js │ ├── apiconstraint.js │ ├── ipgeofirewall.js │ ├── accountprotectionadvancedsettingstep.js │ ├── attackpayloadlogging.js │ ├── custombotcategoryitemsequence.js │ ├── evalpenaltybox.js │ ├── policyprotections.js │ ├── reputationprofile.delete.js │ ├── evalpenaltybox.disable.js │ ├── ratepolicy.create.js │ ├── siem.modify.js │ ├── attackgroups.js │ ├── evalrules.js │ ├── penaltyboxconditions.js │ ├── ratepolicy.actions.js │ ├── customdeny.create.js │ ├── recategorizedakamaidefinedbot.js │ └── attackgroup.disable.js ├── .gitignore └── package.json /templates/action.json: -------------------------------------------------------------------------------- 1 | { 2 | "action": "none" 3 | } 4 | -------------------------------------------------------------------------------- /templates/evalMode.json: -------------------------------------------------------------------------------- 1 | { 2 | "eval": "" 3 | } 4 | -------------------------------------------------------------------------------- /templates/versionNotes.json: -------------------------------------------------------------------------------- 1 | { 2 | "notes": null 3 | } -------------------------------------------------------------------------------- /templates/upgrade.json: -------------------------------------------------------------------------------- 1 | { 2 | "upgrade": false 3 | } 4 | -------------------------------------------------------------------------------- /templates/apipiilearning.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePiiLearning": null 3 | } -------------------------------------------------------------------------------- /templates/evasivepathmatch.json: -------------------------------------------------------------------------------- 1 | { 2 | "enablePathMatch": null 3 | } -------------------------------------------------------------------------------- /templates/httpheaderlogging.json: -------------------------------------------------------------------------------- 1 | { 2 | "allowSampling": null 3 | } -------------------------------------------------------------------------------- /templates/securitypolicyhttpheaderlogging.json: -------------------------------------------------------------------------------- 1 | { 2 | "override": null 3 | } -------------------------------------------------------------------------------- /templates/rename-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "description": "" 4 | } 5 | -------------------------------------------------------------------------------- /templates/recommendation.json: -------------------------------------------------------------------------------- 1 | { 2 | "action": "ACCEPT", 3 | "selectorId": 1 4 | } 5 | -------------------------------------------------------------------------------- /templates/malwarepolicy-action.json: -------------------------------------------------------------------------------- 1 | { 2 | "action" : null, 3 | "unscannedAction" : null 4 | } -------------------------------------------------------------------------------- /templates/penalty-box.json: -------------------------------------------------------------------------------- 1 | { 2 | "action": "none", 3 | "penaltyBoxProtection": false 4 | } -------------------------------------------------------------------------------- /templates/ratepolicy-action.json: -------------------------------------------------------------------------------- 1 | { 2 | "ipv4Action" : null, 3 | "ipv6Action" : null 4 | } -------------------------------------------------------------------------------- /templates/penalty-box-conditions.json: -------------------------------------------------------------------------------- 1 | { 2 | "conditionOperator": "OR", 3 | "conditions": [] 4 | } -------------------------------------------------------------------------------- /templates/eval-penalty-box-conditions.json: -------------------------------------------------------------------------------- 1 | { 2 | "conditionOperator": "OR", 3 | "conditions": [] 4 | } -------------------------------------------------------------------------------- /templates/account-protection-rule-sequence.json: -------------------------------------------------------------------------------- 1 | { 2 | "sequence": [ "user-rule-100000", "user-rule-100001" ] 3 | } 4 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ 2 | fetch-retry-mintimeout=1000 3 | fetch-retry-maxtimeout=5000 4 | strict-ssl=false -------------------------------------------------------------------------------- /templates/reputationanalysis.json: -------------------------------------------------------------------------------- 1 | { 2 | "forwardToHTTPHeader" : null, 3 | "forwardSharedIPToHTTPHeaderAndSIEM" : null 4 | } -------------------------------------------------------------------------------- /templates/apimatchtarget.json: -------------------------------------------------------------------------------- 1 | { 2 | "securityPolicy": { 3 | "policyId": null 4 | }, 5 | "apis": [], 6 | "type": "api" 7 | } -------------------------------------------------------------------------------- /templates/protection.json: -------------------------------------------------------------------------------- 1 | { 2 | "applyApplicationLayerControls": null, 3 | "applyRateControls": null, 4 | "applySlowPostControls": null, 5 | "applyApiConstraints": null 6 | } -------------------------------------------------------------------------------- /templates/matchtarget.json: -------------------------------------------------------------------------------- 1 | { 2 | "securityPolicy": { 3 | "policyId": null 4 | }, 5 | "type": "website", 6 | "hostnames": [], 7 | "filePaths": [], 8 | "isNegativePathMatch": false 9 | } -------------------------------------------------------------------------------- /templates/account-protection-rule.json: -------------------------------------------------------------------------------- 1 | { 2 | "ruleName": "Account Protection Rule", 3 | "clientListId": "11111_CLIENTLIST_ID", 4 | "actionId": "riskActionId", 5 | "areAllOperationsProtected": true, 6 | "operationIds": [] 7 | } 8 | -------------------------------------------------------------------------------- /cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "requirements": { 3 | "node": "22.0.0" 4 | }, 5 | "commands": [ 6 | { 7 | "name": "appsec", 8 | "version": "3.3.0", 9 | "description": "Akamai Security tools for protecting websites." 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /templates/activation.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "", 3 | "action": "ACTIVATE", 4 | "method": "FAST", 5 | "note":"Requested from CLI", 6 | "notificationEmails":[], 7 | "activationConfigs": [ 8 | { 9 | "configId": -1, 10 | "configVersion": -1 11 | } 12 | ], 13 | "acknowledgedInvalidHosts":[] 14 | } 15 | -------------------------------------------------------------------------------- /mock/configs/1234/versions/1/selected-hostnames.json: -------------------------------------------------------------------------------- 1 | { 2 | "responseToChoose": 0, 3 | "responses": [ 4 | { 5 | "httpStatus": 200, 6 | "response": { 7 | "hostnameList": [ 8 | { 9 | "hostname": "*.mss.iss.dlr3.net" 10 | }, 11 | { 12 | "hostname": "b2c.div1.akamaniac.com" 13 | } 14 | ] 15 | } 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /mock/configs/1234/versions/3/selected-hostnames.json: -------------------------------------------------------------------------------- 1 | { 2 | "responseToChoose": 0, 3 | "responses": [ 4 | { 5 | "httpStatus": 200, 6 | "response": { 7 | "hostnameList": [ 8 | { 9 | "hostname": "b2c.div1.akamaniac.com" 10 | }, 11 | { 12 | "hostname": "test-uvm-97-qa.akamaifastdnsdemo.com" 13 | } 14 | ] 15 | } 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /mock/configs/1234.json: -------------------------------------------------------------------------------- 1 | { 2 | "responseToChoose": 0, 3 | "responses":[{ 4 | "httpStatus":200, 5 | "response": 6 | { 7 | "configId": 1234 8 | } 9 | 10 | },{ 11 | "httpStatus":403, 12 | "response": { 13 | "status": 403, 14 | "title":"Unauthorized", 15 | "detail":"You are not authorized to do this!" 16 | } 17 | }] 18 | } -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true, 4 | "es6": true 5 | }, 6 | "extends": "eslint:recommended", 7 | "parserOptions": { 8 | "sourceType": "module" 9 | }, 10 | "rules": { 11 | "no-console":0, 12 | 13 | "linebreak-style": [ 14 | "error", 15 | "unix" 16 | ], 17 | "semi": [ 18 | "error", 19 | "always" 20 | ] 21 | } 22 | } -------------------------------------------------------------------------------- /src/activationhistory.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let Config = require('./configprovider').configProvider; 5 | 6 | class ActivationHistory { 7 | constructor(options) { 8 | this._config = new Config(options); 9 | this._options = options; 10 | } 11 | 12 | getActivationHistory() { 13 | return this._config.readResource(URIs.ACTIVATION_HISTORY, []); 14 | } 15 | } 16 | 17 | module.exports = { 18 | activationHistory: ActivationHistory 19 | }; 20 | -------------------------------------------------------------------------------- /src/responseactions.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let Version = require('./versionsprovider').versionProvider; 5 | 6 | class ResponseActions { 7 | constructor(options) { 8 | this._options = options; 9 | this._version = new Version(options); 10 | } 11 | 12 | getResponseActionsList() { 13 | return this._version.readResource(URIs.RESPONSE_ACTIONS, []); 14 | } 15 | } 16 | 17 | module.exports = { 18 | responseactions: ResponseActions 19 | }; 20 | -------------------------------------------------------------------------------- /mock/configs/1234/versions/2/selected-hostnames.json: -------------------------------------------------------------------------------- 1 | { 2 | "responseToChoose": 0, 3 | "responses": [ 4 | { 5 | "httpStatus": 200, 6 | "response": { 7 | "hostnameList": [ 8 | { 9 | "hostname": "*.mss.iss.dlr3.net" 10 | }, 11 | { 12 | "hostname": "b2c.div1.akamaniac.com" 13 | }, 14 | { 15 | "hostname": "test-uvm-97-qa.akamaifastdnsdemo.com" 16 | } 17 | ] 18 | } 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /templates/pragma-header.json: -------------------------------------------------------------------------------- 1 | { 2 | "action": "REMOVE", 3 | "excludeCondition": [ 4 | { 5 | "type":"requestHeaderValueMatch", 6 | "positiveMatch": true, 7 | "header": "accept", 8 | "value": [ "application/json", "application/xml"], 9 | "valueCase": false, 10 | "valueWildcard": true 11 | }, 12 | { 13 | "type":"ipMatch", 14 | "positiveMatch": true, 15 | "value": [ "1.1.1.1", "192.168.100.14/24"], 16 | "useHeaders": false 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /src/contractgroups.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | let Edge = 3 | process.env.MOCK_AKA_SEC_API == 'true' ? require('../mock/edgeClient') : require('./edgeClient'); 4 | let URIs = require('./constants').URIS; 5 | 6 | class Contractgroups { 7 | constructor(options) { 8 | this._edge = new Edge(options); 9 | this._options = options; 10 | } 11 | 12 | getContractGroups() { 13 | return this._edge.get(URIs.GET_CONTRACT_GROUPS); 14 | } 15 | } 16 | 17 | module.exports = { 18 | contractgroups: Contractgroups 19 | }; 20 | -------------------------------------------------------------------------------- /src/export.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | //let logger = require('./constants').logger('Export'); 5 | let Version = require('./versionsprovider').versionProvider; 6 | 7 | class Export { 8 | constructor(options) { 9 | this._version = new Version(options); 10 | this._options = JSON.parse(JSON.stringify(options)); 11 | } 12 | 13 | export() { 14 | return this._version.readResource(URIs.EXPORT, []); 15 | } 16 | } 17 | 18 | module.exports = { 19 | export: Export 20 | }; 21 | -------------------------------------------------------------------------------- /src/accountprotectionriskactions.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let Version = require('./versionsprovider').versionProvider; 5 | 6 | class AccountProtectionRiskAction { 7 | constructor(options) { 8 | this._options = options; 9 | this._version = new Version(options); 10 | } 11 | 12 | getRiskActions() { 13 | return this._version.readResource(URIs.ACCOUNT_PROTECTION_RISK_ACTIONS, []); 14 | } 15 | } 16 | 17 | module.exports = { 18 | accountProtectionRiskAction: AccountProtectionRiskAction 19 | }; 20 | -------------------------------------------------------------------------------- /src/botanalyticscookievalues.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let Edge = 5 | process.env.MOCK_AKA_SEC_API === 'true' ? require('../mock/edgeClient') : require('./edgeClient'); 6 | 7 | class BotAnalyticsCookieValues { 8 | constructor(options) { 9 | this._options = options; 10 | this._edge = new Edge(options); 11 | } 12 | 13 | getBotAnalyticsCookieValues() { 14 | return this._edge.get(URIs.BOT_ANALYTICS_COOKIE_VALUES, []); 15 | } 16 | } 17 | 18 | module.exports = { 19 | botanalyticscookievalues: BotAnalyticsCookieValues 20 | }; 21 | -------------------------------------------------------------------------------- /mock/configs.json: -------------------------------------------------------------------------------- 1 | { 2 | "responseToChoose": 0, 3 | "responses": [ 4 | { 5 | "httpStatus": 200, 6 | "response": { 7 | "configurations": [ 8 | { 9 | "id": 1234 10 | } 11 | ] 12 | } 13 | }, 14 | { 15 | "httpStatus": 403, 16 | "response": { 17 | "status": 403, 18 | "title": "Unauthorized", 19 | "detail": "You are not authorized to do this!" 20 | } 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /src/botanalyticscookierotatevalues.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let Edge = 5 | process.env.MOCK_AKA_SEC_API === 'true' ? require('../mock/edgeClient') : require('./edgeClient'); 6 | 7 | class BotAnalyticsCookieRotateValues { 8 | constructor(options) { 9 | this._options = options; 10 | this._edge = new Edge(options); 11 | } 12 | 13 | rotateBotAnalyticsCookieValues() { 14 | return this._edge.post(URIs.BOT_ANALYTICS_COOKIE_ROTATE_VALUES, []); 15 | } 16 | } 17 | 18 | module.exports = { 19 | botanalyticscookierotatevalues: BotAnalyticsCookieRotateValues 20 | }; 21 | -------------------------------------------------------------------------------- /src/botdetection.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let Edge = 5 | process.env.MOCK_AKA_SEC_API === 'true' ? require('../mock/edgeClient') : require('./edgeClient'); 6 | 7 | class BotDetection { 8 | constructor(options) { 9 | this._options = options; 10 | this._edge = new Edge(options); 11 | } 12 | 13 | getBotDetectionList() { 14 | return this._edge.get(URIs.BOT_DETECTIONS, []); 15 | } 16 | 17 | getBotDetection() { 18 | return this._edge.get(URIs.BOT_DETECTION, [this._options['bot_detection_id']]); 19 | } 20 | } 21 | 22 | module.exports = { 23 | botdetection: BotDetection 24 | }; 25 | -------------------------------------------------------------------------------- /src/akamaidefinedbot.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let Edge = 5 | process.env.MOCK_AKA_SEC_API === 'true' ? require('../mock/edgeClient') : require('./edgeClient'); 6 | 7 | class AkamaiDefinedBot { 8 | constructor(options) { 9 | this._options = options; 10 | this._edge = new Edge(options); 11 | } 12 | 13 | getAkamaiDefinedBotList() { 14 | return this._edge.get(URIs.AKAMAI_DEFINED_BOTS, []); 15 | } 16 | 17 | getAkamaiDefinedBot() { 18 | return this._edge.get(URIs.AKAMAI_DEFINED_BOT, [this._options['bot_id']]); 19 | } 20 | } 21 | 22 | module.exports = { 23 | akamaidefinedbot: AkamaiDefinedBot 24 | }; 25 | -------------------------------------------------------------------------------- /src/akamaibotcategory.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let Edge = 5 | process.env.MOCK_AKA_SEC_API === 'true' ? require('../mock/edgeClient') : require('./edgeClient'); 6 | 7 | class AkamaiBotCategory { 8 | constructor(options) { 9 | this._options = options; 10 | this._edge = new Edge(options); 11 | } 12 | 13 | getAkamaiBotCategoryList() { 14 | return this._edge.get(URIs.AKAMAI_BOT_CATEGORYS, []); 15 | } 16 | 17 | getAkamaiBotCategory() { 18 | return this._edge.get(URIs.AKAMAI_BOT_CATEGORY, [this._options['category_id']]); 19 | } 20 | } 21 | 22 | module.exports = { 23 | akamaibotcategory: AkamaiBotCategory 24 | }; 25 | -------------------------------------------------------------------------------- /bin/commands/customrule.template.js: -------------------------------------------------------------------------------- 1 | let CRB = require('../../src/crb').CRBHandler; 2 | 3 | class CustomRuleTemplateCommand { 4 | constructor() { 5 | this.flags = 'structured-rule-template'; 6 | this.desc = 'Prints sample JSON of a structured custom rule.'; 7 | this.aliases = ['srt']; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac.usage('Usage: akamai-appsec structured-rule-template').help({ 14 | includeGroups: false 15 | }); 16 | } 17 | 18 | run(options) { 19 | console.log(new CRB(options).template()); 20 | } 21 | } 22 | 23 | module.exports = new CustomRuleTemplateCommand(); 24 | -------------------------------------------------------------------------------- /src/clone.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let Config = require('./configprovider').configProvider; 5 | let Version = require('./versionsprovider').versionProvider; 6 | 7 | class CloneHandler { 8 | constructor(options) { 9 | this._config = new Config(options); 10 | this._version = new Version(options); 11 | this._options = options; 12 | } 13 | 14 | clone() { 15 | return this._version.getVersionNumber().then(version => { 16 | this.ruleUpdate = this._options['rule-update'] || false; 17 | let payload = { createFromVersion: version, ruleUpdate: this.ruleUpdate }; 18 | return this._config.createResource(URIs.CLONE, [], payload); 19 | }); 20 | } 21 | } 22 | 23 | module.exports = { 24 | CloneHandler: CloneHandler 25 | }; 26 | -------------------------------------------------------------------------------- /mock/activations.json: -------------------------------------------------------------------------------- 1 | { 2 | "responseToChoose": 0, 3 | "responses": [ 4 | { 5 | "httpStatus": 202, 6 | "response": { 7 | "statusId": "f81c92c5-b150-4c41-9b53-9cef7969150a", 8 | "createDate": "2018-06-19T11:27:55Z", 9 | "links": { 10 | "check-status": { 11 | "href": "activations/status/f81c92c5-b150-4c41-9b53-9cef7969150a" 12 | } 13 | } 14 | } 15 | }, 16 | { 17 | "httpStatus": 403, 18 | "response": { 19 | "status": 403, 20 | "title": "Unauthorized", 21 | "detail": "You are not authorized to do this!" 22 | } 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /bin/commands/siem.js: -------------------------------------------------------------------------------- 1 | let out = require('./lib/out'); 2 | let SIEM = require('../../src/siemsettings').siemSettings; 3 | 4 | const objectType = 'siemDefinitions'; 5 | 6 | class SIEMDefCommand { 7 | constructor() { 8 | this.flags = 'siem-definitions'; 9 | this.desc = 'List all siem definitions.'; 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | run(options) { 14 | out.print({ 15 | promise: new SIEM(options).getSIEMDefinitions(), 16 | args: options, 17 | objectType, 18 | success: (args, data) => { 19 | let str = []; 20 | data[objectType].forEach(siem => { 21 | str.push(siem.id + ' ' + siem.name); 22 | }); 23 | return str.join(require('os').EOL); 24 | } 25 | }); 26 | } 27 | } 28 | 29 | module.exports = new SIEMDefCommand(); 30 | -------------------------------------------------------------------------------- /bin/commands/contentprotectiondetections.js: -------------------------------------------------------------------------------- 1 | let ContentProtectionRule = require('../../src/contentprotectionrule').contentProtectionRule; 2 | let out = require('./lib/out'); 3 | 4 | class ContentProtectionRuleDetectionsCommand { 5 | constructor() { 6 | this.flags = 'content-protection-detections'; 7 | this.desc = 'Display content protection detections.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) {} 13 | 14 | run(options) { 15 | out.print({ 16 | promise: new ContentProtectionRule(options).getContentProtectionDetections(), 17 | args: options, 18 | success: (args, data) => { 19 | return JSON.stringify(data); 20 | } 21 | }); 22 | } 23 | } 24 | 25 | module.exports = new ContentProtectionRuleDetectionsCommand(); 26 | -------------------------------------------------------------------------------- /bin/commands/botanalyticscookievalues.js: -------------------------------------------------------------------------------- 1 | let BotAnalyticsCookieValues = require('../../src/botanalyticscookievalues') 2 | .botanalyticscookievalues; 3 | let out = require('./lib/out'); 4 | 5 | class BotAnalyticsCookieValuesCommand { 6 | constructor() { 7 | this.flags = 'bot-analytics-cookie-values'; 8 | this.desc = 'Display contents of bot analytics cookie values.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) {} 14 | 15 | run(options) { 16 | out.print({ 17 | promise: new BotAnalyticsCookieValues(options).getBotAnalyticsCookieValues(), 18 | args: options, 19 | success: (args, data) => { 20 | return JSON.stringify(data); 21 | } 22 | }); 23 | } 24 | } 25 | 26 | module.exports = new BotAnalyticsCookieValuesCommand(); 27 | -------------------------------------------------------------------------------- /bin/commands/botendpointcoveragereport.js: -------------------------------------------------------------------------------- 1 | let BotEndpointCoverageReport = require('../../src/botendpointcoveragereport') 2 | .botendpointcoveragereport; 3 | let out = require('./lib/out'); 4 | 5 | class BotEndpointCoverageReportCommand { 6 | constructor() { 7 | this.flags = 'bot-endpoint-coverage-report'; 8 | this.desc = 'Display contents of bot endpoint coverage report.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) {} 14 | 15 | run(options) { 16 | out.print({ 17 | promise: new BotEndpointCoverageReport(options).getBotEndpointCoverageReport(), 18 | args: options, 19 | success: (args, data) => { 20 | return JSON.stringify(data); 21 | } 22 | }); 23 | } 24 | } 25 | 26 | module.exports = new BotEndpointCoverageReportCommand(); 27 | -------------------------------------------------------------------------------- /bin/commands/config.delete.js: -------------------------------------------------------------------------------- 1 | let Config = require('../../src/configprovider').configProvider; 2 | let out = require('./lib/out'); 3 | 4 | class CreateConfigCommand { 5 | constructor() { 6 | this.flags = 'delete-config'; 7 | this.desc = 'Delete a security config.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac.number('--config ', { 14 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 15 | group: 'Optional:', 16 | required: false 17 | }); 18 | } 19 | 20 | run(options) { 21 | out.print({ 22 | promise: new Config(options).deleteConfig(), 23 | args: options, 24 | success: (args, data) => { 25 | return data; 26 | } 27 | }); 28 | } 29 | } 30 | 31 | module.exports = new CreateConfigCommand(); 32 | -------------------------------------------------------------------------------- /bin/commands/rotatebotanalyticscookievalues.js: -------------------------------------------------------------------------------- 1 | let BotAnalyticsCookieRotateValues = require('../../src/botanalyticscookierotatevalues') 2 | .botanalyticscookierotatevalues; 3 | let out = require('./lib/out'); 4 | 5 | class RotateBotAnalyticsCookieValuesCommand { 6 | constructor() { 7 | this.flags = 'rotate-bot-analytics-cookie-values'; 8 | this.desc = 'Rotate bot analytics cookie values.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) {} 14 | 15 | run(options) { 16 | out.print({ 17 | promise: new BotAnalyticsCookieRotateValues(options).rotateBotAnalyticsCookieValues(), 18 | args: options, 19 | success: (args, data) => { 20 | return JSON.stringify(data); 21 | } 22 | }); 23 | } 24 | } 25 | 26 | module.exports = new RotateBotAnalyticsCookieValuesCommand(); 27 | -------------------------------------------------------------------------------- /bin/commands/botdetection.js: -------------------------------------------------------------------------------- 1 | let BotDetection = require('../../src/botdetection').botdetection; 2 | let out = require('./lib/out'); 3 | 4 | class BotDetectionCommand { 5 | constructor() { 6 | this.flags = 'bot-detection'; 7 | this.desc = 'Display contents of bot detection.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac.positional('', { 14 | paramsDesc: 'Bot Detection ID' 15 | }); 16 | } 17 | 18 | run(options) { 19 | options.bot_detection_id = options['bot-detection-id']; 20 | 21 | out.print({ 22 | promise: new BotDetection(options).getBotDetection(), 23 | args: options, 24 | success: (args, data) => { 25 | return JSON.stringify(data); 26 | } 27 | }); 28 | } 29 | } 30 | 31 | module.exports = new BotDetectionCommand(); 32 | -------------------------------------------------------------------------------- /bin/commands/contracts-groups.js: -------------------------------------------------------------------------------- 1 | let ContractsGroups = require('../../src/contractgroups').contractgroups; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'contract_groups'; 5 | 6 | class ContractGroupsCommand { 7 | constructor() { 8 | this.flags = 'contracts-groups'; 9 | this.desc = 'List contracts and groups with KSD/WAP line items.'; 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | run(options) { 14 | out.print({ 15 | promise: new ContractsGroups(options).getContractGroups(), 16 | args: options, 17 | objectType, 18 | success: (args, data) => { 19 | let str = []; 20 | data[objectType].forEach(cg => { 21 | str.push(cg.contractId + ' ' + cg.groupId); 22 | }); 23 | return str.join(require('os').EOL); 24 | } 25 | }); 26 | } 27 | } 28 | 29 | module.exports = new ContractGroupsCommand(); 30 | -------------------------------------------------------------------------------- /src/versionnotes.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let fs = require('fs'); 5 | let Config = require('./configprovider').configProvider; 6 | let Version = require('./versionsprovider').versionProvider; 7 | 8 | class VersionNotes { 9 | constructor(options) { 10 | this._config = new Config(options); 11 | this._options = options; 12 | this._version = new Version(options); 13 | } 14 | 15 | getVersionNotes() { 16 | return this._version.readResource(URIs.VERSION_NOTES, []); 17 | } 18 | 19 | updateVersionNotes() { 20 | let json = JSON.parse(fs.readFileSync(__dirname + '/../templates/versionNotes.json', 'utf8')); 21 | json.notes = this._options['notes'] ? this._options['notes'] : ''; 22 | return this._version.updateResource(URIs.VERSION_NOTES, [], json); 23 | } 24 | } 25 | 26 | module.exports = { 27 | versionNotes: VersionNotes 28 | }; 29 | -------------------------------------------------------------------------------- /bin/commands/akamaidefinedbot.js: -------------------------------------------------------------------------------- 1 | let AkamaiDefinedBot = require('../../src/akamaidefinedbot').akamaidefinedbot; 2 | let out = require('./lib/out'); 3 | 4 | class AkamaiDefinedBotCommand { 5 | constructor() { 6 | this.flags = 'akamai-defined-bot'; 7 | this.desc = 'Display contents of akamai defined bot.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac.positional('', { 14 | paramsDesc: 'Akamai Defined Bot ID' 15 | }); 16 | } 17 | 18 | run(options) { 19 | options.bot_id = options['bot-id']; 20 | 21 | out.print({ 22 | promise: new AkamaiDefinedBot(options).getAkamaiDefinedBot(), 23 | args: options, 24 | success: (args, data) => { 25 | return JSON.stringify(data); 26 | } 27 | }); 28 | } 29 | } 30 | 31 | module.exports = new AkamaiDefinedBotCommand(); 32 | -------------------------------------------------------------------------------- /src/mode.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | //Ensures user can add paths like '~/foo' 5 | let Version = require('./versionsprovider').versionProvider; 6 | let PolicyProvider = require('./policy').policy; 7 | 8 | class Mode { 9 | constructor(options) { 10 | this._options = options; 11 | this._version = new Version(options); 12 | this._policyProvider = new PolicyProvider(options); 13 | } 14 | 15 | getMode() { 16 | return this._policyProvider.policyId().then(policyId => { 17 | return this._version.readResource(URIs.MODE, [policyId]); 18 | }); 19 | } 20 | 21 | setMode() { 22 | let payload = { mode: this._options.mode }; 23 | return this._policyProvider.policyId().then(policyId => { 24 | return this._version.updateResource(URIs.MODE, [policyId], payload); 25 | }); 26 | } 27 | } 28 | 29 | module.exports = { 30 | mode: Mode 31 | }; 32 | -------------------------------------------------------------------------------- /src/apiendpoints.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let Config = require('./configprovider').configProvider; 5 | let Version = require('./versionsprovider').versionProvider; 6 | let PolicyProvider = require('./policy').policy; 7 | 8 | class APIEndpoints { 9 | constructor(options) { 10 | this._config = new Config(options); 11 | this._options = options; 12 | this._version = new Version(options); 13 | this._policyProvider = new PolicyProvider(options); 14 | } 15 | 16 | getAllAPIEndpoints() { 17 | if (this._options.policy) { 18 | return this._policyProvider.policyId().then(policyId => { 19 | return this._version.readResource(URIs.SECURITY_POLICY_API_ENDPOINTS, [policyId]); 20 | }); 21 | } 22 | return this._version.readResource(URIs.API_ENDPOINTS, []); 23 | } 24 | } 25 | 26 | module.exports = { 27 | apiEndpoints: APIEndpoints 28 | }; 29 | -------------------------------------------------------------------------------- /src/botendpointcoveragereport.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Version = require('./versionsprovider').versionProvider; 7 | let Edge = 8 | process.env.MOCK_AKA_SEC_API === 'true' ? require('../mock/edgeClient') : require('./edgeClient'); 9 | 10 | class BotEndpointCoverageReport { 11 | constructor(options) { 12 | this._options = options; 13 | this._edge = new Edge(options); 14 | this._version = new Version(options); 15 | } 16 | 17 | getBotEndpointCoverageReport() { 18 | return this._edge.get(URIs.BOT_ENDPOINT_COVERAGE_REPORTS, []); 19 | } 20 | 21 | getBotEndpointCoverageReportConfigVersion() { 22 | return this._version.readResource(URIs.BOT_ENDPOINT_COVERAGE_REPORT, []); 23 | } 24 | } 25 | 26 | module.exports = { 27 | botendpointcoveragereport: BotEndpointCoverageReport 28 | }; 29 | -------------------------------------------------------------------------------- /bin/commands/botdetectionlist.js: -------------------------------------------------------------------------------- 1 | let BotDetection = require('../../src/botdetection').botdetection; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'detections'; 5 | 6 | class ListBotDetectionCommand { 7 | constructor() { 8 | this.flags = 'bot-detection-list'; 9 | this.desc = 'List all bot detection.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) {} 15 | 16 | run(options) { 17 | out.print({ 18 | promise: new BotDetection(options).getBotDetectionList(), 19 | args: options, 20 | objectType, 21 | success: (args, data) => { 22 | let str = []; 23 | data[objectType].forEach(action => { 24 | str.push(action.detectionId); 25 | }); 26 | return str.join(require('os').EOL); 27 | } 28 | }); 29 | } 30 | } 31 | 32 | module.exports = new ListBotDetectionCommand(); 33 | -------------------------------------------------------------------------------- /bin/commands/akamaibotcategory.js: -------------------------------------------------------------------------------- 1 | let AkamaiBotCategory = require('../../src/akamaibotcategory').akamaibotcategory; 2 | let out = require('./lib/out'); 3 | 4 | class AkamaiBotCategoryCommand { 5 | constructor() { 6 | this.flags = 'akamai-bot-category'; 7 | this.desc = 'Display contents of akamai bot category.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac.positional('', { 14 | paramsDesc: 'Akamai Bot Category ID' 15 | }); 16 | } 17 | 18 | run(options) { 19 | options.category_id = options['category-id']; 20 | 21 | out.print({ 22 | promise: new AkamaiBotCategory(options).getAkamaiBotCategory(), 23 | args: options, 24 | success: (args, data) => { 25 | return JSON.stringify(data); 26 | } 27 | }); 28 | } 29 | } 30 | 31 | module.exports = new AkamaiBotCategoryCommand(); 32 | -------------------------------------------------------------------------------- /bin/commands/akamaidefinedbotlist.js: -------------------------------------------------------------------------------- 1 | let AkamaiDefinedBot = require('../../src/akamaidefinedbot').akamaidefinedbot; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'bots'; 5 | 6 | class ListAkamaiDefinedBotCommand { 7 | constructor() { 8 | this.flags = 'akamai-defined-bot-list'; 9 | this.desc = 'List all akamai defined bot.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) {} 15 | 16 | run(options) { 17 | out.print({ 18 | promise: new AkamaiDefinedBot(options).getAkamaiDefinedBotList(), 19 | args: options, 20 | objectType, 21 | success: (args, data) => { 22 | let str = []; 23 | data[objectType].forEach(action => { 24 | str.push(action.botId); 25 | }); 26 | return str.join(require('os').EOL); 27 | } 28 | }); 29 | } 30 | } 31 | 32 | module.exports = new ListAkamaiDefinedBotCommand(); 33 | -------------------------------------------------------------------------------- /bin/commands/akamaibotcategorylist.js: -------------------------------------------------------------------------------- 1 | let AkamaiBotCategory = require('../../src/akamaibotcategory').akamaibotcategory; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'categories'; 5 | 6 | class ListAkamaiBotCategoryCommand { 7 | constructor() { 8 | this.flags = 'akamai-bot-category-list'; 9 | this.desc = 'List all akamai bot category.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) {} 15 | 16 | run(options) { 17 | out.print({ 18 | promise: new AkamaiBotCategory(options).getAkamaiBotCategoryList(), 19 | args: options, 20 | objectType, 21 | success: (args, data) => { 22 | let str = []; 23 | data[objectType].forEach(action => { 24 | str.push(action.categoryId); 25 | }); 26 | return str.join(require('os').EOL); 27 | } 28 | }); 29 | } 30 | } 31 | 32 | module.exports = new ListAkamaiBotCategoryCommand(); 33 | -------------------------------------------------------------------------------- /bin/commands/customrules.js: -------------------------------------------------------------------------------- 1 | let CRB = require('../../src/crb').CRBHandler; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'customRules'; 5 | 6 | class ListCustomRulesCommand { 7 | constructor() { 8 | this.flags = 'custom-rules'; 9 | this.desc = 'List all custom rules.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac.number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }); 20 | } 21 | run(options) { 22 | out.print({ 23 | promise: new CRB(options).getAllRules(), 24 | args: options, 25 | objectType, 26 | success: (args, data) => { 27 | let str = []; 28 | data[objectType].forEach(rule => { 29 | str.push(rule.id); 30 | }); 31 | return str.join(require('os').EOL); 32 | } 33 | }); 34 | } 35 | } 36 | 37 | module.exports = new ListCustomRulesCommand(); 38 | -------------------------------------------------------------------------------- /bin/commands/config.clone.js: -------------------------------------------------------------------------------- 1 | let Config = require('../../src/configprovider').configProvider; 2 | let out = require('./lib/out'); 3 | 4 | class CloneConfigCommand { 5 | constructor() { 6 | this.flags = 'clone-config'; 7 | this.desc = 'Clone a new security config.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('<@path>', { 15 | paramsDesc: 'The input file path.' 16 | }) 17 | .check((argv, context) => { 18 | if (!argv['@path'].startsWith('@')) { 19 | return context.cliMessage("ERROR: Invalid file name, should start with '@'"); 20 | } 21 | }); 22 | } 23 | 24 | run(options) { 25 | options.file = options['@path'].replace('@', ''); 26 | 27 | out.print({ 28 | promise: new Config(options).cloneConfig(), 29 | args: options, 30 | success: (args, data) => { 31 | return JSON.stringify(data.configId); 32 | } 33 | }); 34 | } 35 | } 36 | 37 | module.exports = new CloneConfigCommand(); 38 | -------------------------------------------------------------------------------- /bin/commands/config.create.js: -------------------------------------------------------------------------------- 1 | let Config = require('../../src/configprovider').configProvider; 2 | let out = require('./lib/out'); 3 | 4 | class CreateConfigCommand { 5 | constructor() { 6 | this.flags = 'create-config'; 7 | this.desc = 'Create a new security config.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('<@path>', { 15 | paramsDesc: 'The input file path.' 16 | }) 17 | .check((argv, context) => { 18 | if (!argv['@path'].startsWith('@')) { 19 | return context.cliMessage("ERROR: Invalid file name, should start with '@'"); 20 | } 21 | }); 22 | } 23 | 24 | run(options) { 25 | options.file = options['@path'].replace('@', ''); 26 | 27 | out.print({ 28 | promise: new Config(options).createConfig(), 29 | args: options, 30 | success: (args, data) => { 31 | return JSON.stringify(data.configId); 32 | } 33 | }); 34 | } 35 | } 36 | 37 | module.exports = new CreateConfigCommand(); 38 | -------------------------------------------------------------------------------- /mock/configs/1234/versions/1/activations/1.json: -------------------------------------------------------------------------------- 1 | { 2 | "responseToChoose": 0, 3 | "responses":[{ 4 | "httpStatus":200, 5 | "response": { 6 | "statusCode":200, 7 | "body":{ 8 | "activationId": 1234, 9 | "action": "ACTIVATE", 10 | "status": "RECEIVED", 11 | "network": "PRODUCTION", 12 | "estimate": "PTM5", 13 | "activationConfigs": [ 14 | { 15 | "configId": 1, 16 | "configName": "config 1", 17 | "configVersion": 4, 18 | "previousConfigVersion": 2 19 | } 20 | ], 21 | "createdBy": "user1", 22 | "createDate": "2013-10-07T17:41:52+00:00" 23 | } 24 | } 25 | }, { 26 | "httpStatus":403, 27 | "response": { 28 | "status": 403, 29 | "title":"Unauthorized", 30 | "detail":"You are not authorized to do this!" 31 | } 32 | }] 33 | } -------------------------------------------------------------------------------- /src/googlerecaptchasecretkey.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Version = require('./versionsprovider').versionProvider; 7 | 8 | class GoogleRecaptchaSecretKey { 9 | constructor(options) { 10 | this._options = options; 11 | this._version = new Version(options); 12 | } 13 | 14 | updateGoogleRecaptchaSecretKey() { 15 | if (fs.existsSync(untildify(this._options['file']))) { 16 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 17 | let data; 18 | try { 19 | data = JSON.parse(payload); 20 | } catch (err) { 21 | throw 'The input JSON is not valid'; 22 | } 23 | return this._version.updateResource( 24 | URIs.GOOGLE_RECAPTCHA_SECRET_KEY, 25 | [this._options['action_id']], 26 | data 27 | ); 28 | } else { 29 | throw `The file does not exists: ${this._options['file']}`; 30 | } 31 | } 32 | } 33 | 34 | module.exports = { 35 | googlerecaptchasecretkey: GoogleRecaptchaSecretKey 36 | }; 37 | -------------------------------------------------------------------------------- /bin/commands/hosts.failover.js: -------------------------------------------------------------------------------- 1 | let out = require('./lib/out'); 2 | let SelectedHosts = require('../../src/hosts').selectedHosts; 3 | 4 | const objectType = 'hostnameList'; 5 | 6 | class SelectableHostsCommand { 7 | constructor() { 8 | this.flags = 'failover-hostnames'; 9 | this.desc = 'List all failover hostnames.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac.number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }); 20 | } 21 | 22 | run(options) { 23 | out.print({ 24 | promise: new SelectedHosts(options).failoverHosts(), 25 | args: options, 26 | objectType, 27 | success: (args, data) => { 28 | let hosts = []; 29 | data[objectType].forEach(host => { 30 | hosts.push(host.hostname); 31 | }); 32 | return hosts.join(require('os').EOL); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new SelectableHostsCommand(); 39 | -------------------------------------------------------------------------------- /src/botanalyticscookie.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Version = require('./versionsprovider').versionProvider; 7 | 8 | class BotAnalyticsCookie { 9 | constructor(options) { 10 | this._options = options; 11 | this._version = new Version(options); 12 | } 13 | 14 | getBotAnalyticsCookie() { 15 | return this._version.readResource(URIs.BOT_ANALYTICS_COOKIE, []); 16 | } 17 | 18 | updateBotAnalyticsCookie() { 19 | if (fs.existsSync(untildify(this._options['file']))) { 20 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 21 | let data; 22 | try { 23 | data = JSON.parse(payload); 24 | } catch (err) { 25 | throw 'The input JSON is not valid'; 26 | } 27 | return this._version.updateResource(URIs.BOT_ANALYTICS_COOKIE, [], data); 28 | } else { 29 | throw `The file does not exists: ${this._options['file']}`; 30 | } 31 | } 32 | } 33 | 34 | module.exports = { 35 | botanalyticscookie: BotAnalyticsCookie 36 | }; 37 | -------------------------------------------------------------------------------- /src/botmanagementsettings.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Policy = require('./policy').policy; 7 | 8 | class BotManagementSettings { 9 | constructor(options) { 10 | this._options = options; 11 | this._policy = new Policy(options); 12 | } 13 | 14 | getBotManagementSettings() { 15 | return this._policy.readResource(URIs.BOT_MANAGEMENT_SETTINGS, []); 16 | } 17 | 18 | updateBotManagementSettings() { 19 | if (fs.existsSync(untildify(this._options['file']))) { 20 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 21 | let data; 22 | try { 23 | data = JSON.parse(payload); 24 | } catch (err) { 25 | throw 'The input JSON is not valid'; 26 | } 27 | return this._policy.updateResource(URIs.BOT_MANAGEMENT_SETTINGS, [], data); 28 | } else { 29 | throw `The file does not exists: ${this._options['file']}`; 30 | } 31 | } 32 | } 33 | 34 | module.exports = { 35 | botmanagementsettings: BotManagementSettings 36 | }; 37 | -------------------------------------------------------------------------------- /src/clientsidesecurity.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Version = require('./versionsprovider').versionProvider; 7 | 8 | class ClientSideSecurity { 9 | constructor(options) { 10 | this._options = options; 11 | this._version = new Version(options); 12 | } 13 | 14 | getClientSideSecurity() { 15 | return this._version.readResource(URIs.CLIENT_SIDE_SECURITY, []); 16 | } 17 | 18 | updateClientSideSecurity() { 19 | if (fs.existsSync(untildify(this._options['file']))) { 20 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 21 | let data; 22 | try { 23 | data = JSON.parse(payload); 24 | } catch (err) { 25 | throw 'The input JSON is not valid'; 26 | } 27 | return this._version.updateResource(URIs.CLIENT_SIDE_SECURITY, [], data); 28 | } else { 29 | throw `The file does not exists: ${this._options['file']}`; 30 | } 31 | } 32 | } 33 | 34 | module.exports = { 35 | clientsidesecurity: ClientSideSecurity 36 | }; 37 | -------------------------------------------------------------------------------- /bin/commands/customrule.delete.js: -------------------------------------------------------------------------------- 1 | let CRB = require('../../src/crb').CRBHandler; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteCustomRuleCommand { 5 | constructor() { 6 | this.flags = 'delete-custom-rule'; 7 | this.desc = 'Delete a custom rule.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .usage('Usage: akamai-appsec delete-custom-rule --custom-rule [options]') 15 | .number('--custom-rule ', { 16 | desc: 'Custom rule ID.', 17 | group: 'Required:', 18 | required: true 19 | }) 20 | .number('--config ', { 21 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 22 | group: 'Optional:', 23 | required: false 24 | }); 25 | } 26 | 27 | run(options) { 28 | out.print({ 29 | promise: new CRB(options).deleteRule(), 30 | args: options, 31 | success: (args, data) => { 32 | return data; 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new DeleteCustomRuleCommand(); 39 | -------------------------------------------------------------------------------- /src/botprotectionexceptions.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Policy = require('./policy').policy; 7 | 8 | class BotProtectionExceptions { 9 | constructor(options) { 10 | this._options = options; 11 | this._policy = new Policy(options); 12 | } 13 | 14 | getBotProtectionExceptions() { 15 | return this._policy.readResource(URIs.BOT_PROTECTION_EXCEPTIONS, []); 16 | } 17 | 18 | updateBotProtectionExceptions() { 19 | if (fs.existsSync(untildify(this._options['file']))) { 20 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 21 | let data; 22 | try { 23 | data = JSON.parse(payload); 24 | } catch (err) { 25 | throw 'The input JSON is not valid'; 26 | } 27 | return this._policy.updateResource(URIs.BOT_PROTECTION_EXCEPTIONS, [], data); 28 | } else { 29 | throw `The file does not exists: ${this._options['file']}`; 30 | } 31 | } 32 | } 33 | 34 | module.exports = { 35 | botprotectionexceptions: BotProtectionExceptions 36 | }; 37 | -------------------------------------------------------------------------------- /src/customclientsequence.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Version = require('./versionsprovider').versionProvider; 7 | 8 | class CustomClientSequence { 9 | constructor(options) { 10 | this._options = options; 11 | this._version = new Version(options); 12 | } 13 | 14 | getCustomClientSequence() { 15 | return this._version.readResource(URIs.CUSTOM_CLIENT_SEQUENCE, []); 16 | } 17 | 18 | updateCustomClientSequence() { 19 | if (fs.existsSync(untildify(this._options['file']))) { 20 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 21 | let data; 22 | try { 23 | data = JSON.parse(payload); 24 | } catch (err) { 25 | throw 'The input JSON is not valid'; 26 | } 27 | return this._version.updateResource(URIs.CUSTOM_CLIENT_SEQUENCE, [], data); 28 | } else { 29 | throw `The file does not exists: ${this._options['file']}`; 30 | } 31 | } 32 | } 33 | 34 | module.exports = { 35 | customClientSequence: CustomClientSequence 36 | }; 37 | -------------------------------------------------------------------------------- /bin/commands/export.js: -------------------------------------------------------------------------------- 1 | let Export = require('../../src/export').export; 2 | let out = require('./lib/out'); 3 | 4 | class ExportCommand { 5 | constructor() { 6 | this.flags = 'export'; 7 | this.desc = 'Export a configuration version.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }); 25 | } 26 | 27 | run(options) { 28 | out.print({ 29 | promise: new Export(options).export(), 30 | args: options, 31 | success: (args, data) => { 32 | return JSON.stringify(data); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new ExportCommand(); 39 | -------------------------------------------------------------------------------- /src/javascriptinjectionrules.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Policy = require('./policy').policy; 7 | 8 | class JavascriptInjectionRules { 9 | constructor(options) { 10 | this._options = options; 11 | this._policy = new Policy(options); 12 | } 13 | 14 | getJavascriptInjectionRules() { 15 | return this._policy.readResource(URIs.JAVA_SCRIPT_INJECTION_RULES, []); 16 | } 17 | 18 | updateJavascriptInjectionRules() { 19 | if (fs.existsSync(untildify(this._options['file']))) { 20 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 21 | let data; 22 | try { 23 | data = JSON.parse(payload); 24 | } catch (err) { 25 | throw 'The input JSON is not valid'; 26 | } 27 | return this._policy.updateResource(URIs.JAVA_SCRIPT_INJECTION_RULES, [], data); 28 | } else { 29 | throw `The file does not exists: ${this._options['file']}`; 30 | } 31 | } 32 | } 33 | 34 | module.exports = { 35 | javascriptinjectionrules: JavascriptInjectionRules 36 | }; 37 | -------------------------------------------------------------------------------- /bin/commands/customrule.create.js: -------------------------------------------------------------------------------- 1 | let CRB = require('../../src/crb').CRBHandler; 2 | let out = require('./lib/out'); 3 | 4 | class CreateCustomRuleCommand { 5 | constructor() { 6 | this.flags = 'create-custom-rule'; 7 | this.desc = 'Create a custom rule.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .usage('Usage: akamai-appsec create-custom-rule --file [options]') 15 | .file('--file ', { 16 | desc: 'File with JSON rules', 17 | group: 'Required:', 18 | required: true, 19 | mustExist: true 20 | }) 21 | .number('--config ', { 22 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | 28 | run(options) { 29 | out.print({ 30 | promise: new CRB(options).createRule(), 31 | args: options, 32 | success: (args, data) => { 33 | return data.id; 34 | } 35 | }); 36 | } 37 | } 38 | 39 | module.exports = new CreateCustomRuleCommand(); 40 | -------------------------------------------------------------------------------- /src/threatintel.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let fs = require('fs'); 5 | let untildify = require('untildify'); 6 | let Config = require('./configprovider').configProvider; 7 | let Version = require('./versionsprovider').versionProvider; 8 | let PolicyProvider = require('./policy').policy; 9 | 10 | class ThreatIntel { 11 | constructor(options) { 12 | this._config = new Config(options); 13 | this._options = options; 14 | this._version = new Version(options); 15 | this._policyProvider = new PolicyProvider(options); 16 | } 17 | 18 | getThreatIntel() { 19 | return this._policyProvider.policyId().then(policyId => { 20 | return this._version.readResource(URIs.THREAT_INTEL, [policyId]); 21 | }); 22 | } 23 | 24 | toggleThreatIntel(toggle) { 25 | return this._policyProvider.policyId().then(policyId => { 26 | let json = { threatIntel: toggle}; 27 | return this._version.updateResource( 28 | URIs.THREAT_INTEL, 29 | [policyId], 30 | json 31 | ); 32 | }); 33 | } 34 | 35 | } 36 | 37 | module.exports = { 38 | threatIntel: ThreatIntel 39 | }; 40 | -------------------------------------------------------------------------------- /src/challengeinjectionrules.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Version = require('./versionsprovider').versionProvider; 7 | 8 | class ChallengeInjectionRules { 9 | constructor(options) { 10 | this._options = options; 11 | this._version = new Version(options); 12 | } 13 | 14 | getChallengeInjectionRules() { 15 | return this._version.readResource(URIs.CHALLENGE_INJECTION_RULES, []); 16 | } 17 | 18 | updateChallengeInjectionRules() { 19 | if (fs.existsSync(untildify(this._options['file']))) { 20 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 21 | let data; 22 | try { 23 | data = JSON.parse(payload); 24 | } catch (err) { 25 | throw 'The input JSON is not valid'; 26 | } 27 | return this._version.updateResource(URIs.CHALLENGE_INJECTION_RULES, [], data); 28 | } else { 29 | throw `The file does not exists: ${this._options['file']}`; 30 | } 31 | } 32 | } 33 | 34 | module.exports = { 35 | challengeinjectionrules: ChallengeInjectionRules 36 | }; 37 | -------------------------------------------------------------------------------- /src/custombotcategorysequence.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Version = require('./versionsprovider').versionProvider; 7 | 8 | class CustomBotCategorySequence { 9 | constructor(options) { 10 | this._options = options; 11 | this._version = new Version(options); 12 | } 13 | 14 | getCustomBotCategorySequence() { 15 | return this._version.readResource(URIs.CUSTOM_BOT_CATEGORY_SEQUENCE, []); 16 | } 17 | 18 | updateCustomBotCategorySequence() { 19 | if (fs.existsSync(untildify(this._options['file']))) { 20 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 21 | let data; 22 | try { 23 | data = JSON.parse(payload); 24 | } catch (err) { 25 | throw 'The input JSON is not valid'; 26 | } 27 | return this._version.updateResource(URIs.CUSTOM_BOT_CATEGORY_SEQUENCE, [], data); 28 | } else { 29 | throw `The file does not exists: ${this._options['file']}`; 30 | } 31 | } 32 | } 33 | 34 | module.exports = { 35 | custombotcategorysequence: CustomBotCategorySequence 36 | }; 37 | -------------------------------------------------------------------------------- /bin/commands/siemsettings.js: -------------------------------------------------------------------------------- 1 | let SiemSettings = require('../../src/siemsettings').siemSettings; 2 | let out = require('./lib/out'); 3 | 4 | class SIEMSettingsCommand { 5 | constructor() { 6 | this.flags = 'siem'; 7 | this.desc = 'Display the siem settings.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }); 25 | } 26 | 27 | run(options) { 28 | out.print({ 29 | promise: new SiemSettings(options).getSIEMSettings(), 30 | args: options, 31 | success: (args, data) => { 32 | return JSON.stringify(data); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new SIEMSettingsCommand(); 39 | -------------------------------------------------------------------------------- /src/contentprotectionrulesequence.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Policy = require('./policy').policy; 7 | 8 | class ContentProtectionRuleSequence { 9 | constructor(options) { 10 | this._options = options; 11 | this._policy = new Policy(options); 12 | } 13 | 14 | getContentProtectionRuleSequence() { 15 | return this._policy.readResource(URIs.CONTENT_PROTECTION_RULE_SEQUENCE, []); 16 | } 17 | 18 | updateContentProtectionRuleSequence() { 19 | if (fs.existsSync(untildify(this._options['file']))) { 20 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 21 | let data; 22 | try { 23 | data = JSON.parse(payload); 24 | } catch (err) { 25 | throw 'The input JSON is not valid'; 26 | } 27 | return this._policy.updateResource(URIs.CONTENT_PROTECTION_RULE_SEQUENCE, [], data); 28 | } else { 29 | throw `The file does not exists: ${this._options['file']}`; 30 | } 31 | } 32 | } 33 | 34 | module.exports = { 35 | contentProtectionRuleSequence: ContentProtectionRuleSequence 36 | }; 37 | -------------------------------------------------------------------------------- /src/accountprotectionpolicysettings.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Policy = require('./policy').policy; 7 | 8 | class AccountProtectionPolicySettings { 9 | constructor(options) { 10 | this._options = options; 11 | this._policy = new Policy(options); 12 | } 13 | 14 | getAccountProtectionSettings() { 15 | return this._policy.readResource(URIs.ACCOUNT_PROTECTION_SETTINGS, []); 16 | } 17 | 18 | updateAccountProtectionSettings() { 19 | if (!fs.existsSync(untildify(this._options['file']))) { 20 | throw `File ( ${this._options['file']} ) does not exists.`; 21 | } 22 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 23 | let data; 24 | try { 25 | data = JSON.parse(payload); 26 | } catch (err) { 27 | throw `Request payload from file ( ${this._options['file']} ) is not valid json.`; 28 | } 29 | return this._policy.updateResource(URIs.ACCOUNT_PROTECTION_SETTINGS, [], data); 30 | } 31 | } 32 | 33 | module.exports = { 34 | accountProtectionPolicySettings: AccountProtectionPolicySettings 35 | }; 36 | -------------------------------------------------------------------------------- /bin/commands/activationhistory.js: -------------------------------------------------------------------------------- 1 | let ActivationHistory = require('../../src/activationhistory').activationHistory; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'activationHistory'; 5 | 6 | class GetActivationHistoryCommand { 7 | constructor() { 8 | this.flags = 'activation-history'; 9 | this.desc = 'List activation history for the configuration.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac.number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }); 20 | } 21 | 22 | run(options) { 23 | out.print({ 24 | promise: new ActivationHistory(options).getActivationHistory(), 25 | args: options, 26 | objectType, 27 | success: (args, data) => { 28 | let s = []; 29 | data[objectType].forEach(activation => { 30 | s.push(activation.activationId); 31 | }); 32 | return s.join(require('os').EOL); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new GetActivationHistoryCommand(); 39 | -------------------------------------------------------------------------------- /bin/commands/versionnotes.js: -------------------------------------------------------------------------------- 1 | let VersionNotes = require('../../src/versionnotes').versionNotes; 2 | let out = require('./lib/out'); 3 | 4 | class VersionNotesCommand { 5 | constructor() { 6 | this.flags = 'version-notes'; 7 | this.desc = 'Display the version notes.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Options:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Options:', 23 | required: false 24 | }); 25 | } 26 | run(options) { 27 | out.print({ 28 | promise: new VersionNotes(options).getVersionNotes(), 29 | args: options, 30 | success: (args, data) => { 31 | return data.notes ? data.notes : ''; 32 | } 33 | }); 34 | } 35 | } 36 | 37 | module.exports = new VersionNotesCommand(); 38 | -------------------------------------------------------------------------------- /mock/configs/1234/custom-rules.json: -------------------------------------------------------------------------------- 1 | { 2 | "responseToChoose": 0, 3 | "responses":[ { 4 | "httpStatus":200, 5 | "response": [ 6 | { 7 | "link": "/appsec-resource/v1/configs/99999/customRules/111111", 8 | "name": "Example 1", 9 | "status": "activated", 10 | "ruleId": 111111, 11 | "version": 1 12 | }, 13 | { 14 | "link": "/appsec-resource/v1/configs/99999/customRules/111112", 15 | "name": "Example 2", 16 | "status": "published", 17 | "ruleId": 111112, 18 | "version": 1 19 | }, 20 | { 21 | "link": "/appsec-resource/v1/configs/99999/customRules/111113", 22 | "name": "Example 3", 23 | "status": "unused", 24 | "ruleId": 111113, 25 | "version": 2 26 | } 27 | ] 28 | }, { 29 | "httpStatus":403, 30 | "response": { 31 | "title": "Unauthorized", 32 | "detail": "You are not authorized to perform this operation" 33 | } 34 | } ] 35 | } -------------------------------------------------------------------------------- /src/accountProtectionRuleSequence.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Policy = require('./policy').policy; 7 | 8 | class AccountProtectionRuleSequence { 9 | constructor(options) { 10 | this._options = options; 11 | this._policy = new Policy(options); 12 | } 13 | 14 | getAccountProtectionRuleSequence() { 15 | return this._policy.readResource(URIs.ACCOUNT_PROTECTION_RULE_SEQUENCE, []); 16 | } 17 | 18 | modifyAccountProtectionRuleSequence() { 19 | if (!fs.existsSync(untildify(this._options['file']))) { 20 | throw `File ( ${this._options['file']} ) does not exists.`; 21 | } 22 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 23 | let data; 24 | try { 25 | data = JSON.parse(payload); 26 | } catch (err) { 27 | throw `Request payload from file ( ${this._options['file']} ) is not valid json.`; 28 | } 29 | return this._policy.updateResource(URIs.ACCOUNT_PROTECTION_RULE_SEQUENCE, [], data); 30 | } 31 | } 32 | 33 | module.exports = { 34 | accountProtectionRuleSequence: AccountProtectionRuleSequence 35 | }; 36 | -------------------------------------------------------------------------------- /src/transactionalendpointprotection.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Version = require('./versionsprovider').versionProvider; 7 | 8 | class TransactionalEndpointProtection { 9 | constructor(options) { 10 | this._options = options; 11 | this._version = new Version(options); 12 | } 13 | 14 | getTransactionalEndpointProtection() { 15 | return this._version.readResource(URIs.TRANSACTIONAL_ENDPOINT_PROTECTION, []); 16 | } 17 | 18 | updateTransactionalEndpointProtection() { 19 | if (fs.existsSync(untildify(this._options['file']))) { 20 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 21 | let data; 22 | try { 23 | data = JSON.parse(payload); 24 | } catch (err) { 25 | throw 'The input JSON is not valid'; 26 | } 27 | return this._version.updateResource(URIs.TRANSACTIONAL_ENDPOINT_PROTECTION, [], data); 28 | } else { 29 | throw `The file does not exists: ${this._options['file']}`; 30 | } 31 | } 32 | } 33 | 34 | module.exports = { 35 | transactionalendpointprotection: TransactionalEndpointProtection 36 | }; 37 | -------------------------------------------------------------------------------- /bin/commands/version.delete.js: -------------------------------------------------------------------------------- 1 | let Version = require('../../src/versionsprovider').versionProvider; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteConfigVersionCommand { 5 | constructor() { 6 | this.flags = 'delete-config-version'; 7 | this.desc = 'Delete a security config version.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }); 25 | } 26 | 27 | run(options) { 28 | //get args 29 | out.print({ 30 | promise: new Version(options).deleteConfigVersion(), 31 | args: options, 32 | success: (args, data) => { 33 | return data; 34 | } 35 | }); 36 | } 37 | } 38 | 39 | module.exports = new DeleteConfigVersionCommand(); 40 | -------------------------------------------------------------------------------- /bin/commands/botanalyticscookie.js: -------------------------------------------------------------------------------- 1 | let BotAnalyticsCookie = require('../../src/botanalyticscookie').botanalyticscookie; 2 | let out = require('./lib/out'); 3 | 4 | class BotAnalyticsCookieCommand { 5 | constructor() { 6 | this.flags = 'bot-analytics-cookie'; 7 | this.desc = 'Display contents of bot analytics cookie.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }); 25 | } 26 | 27 | run(options) { 28 | out.print({ 29 | promise: new BotAnalyticsCookie(options).getBotAnalyticsCookie(), 30 | args: options, 31 | success: (args, data) => { 32 | return JSON.stringify(data); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new BotAnalyticsCookieCommand(); 39 | -------------------------------------------------------------------------------- /bin/commands/clientsidesecurity.js: -------------------------------------------------------------------------------- 1 | let ClientSideSecurity = require('../../src/clientsidesecurity').clientsidesecurity; 2 | let out = require('./lib/out'); 3 | 4 | class ClientSideSecurityCommand { 5 | constructor() { 6 | this.flags = 'client-side-security'; 7 | this.desc = 'Display contents of client side security.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }); 25 | } 26 | 27 | run(options) { 28 | out.print({ 29 | promise: new ClientSideSecurity(options).getClientSideSecurity(), 30 | args: options, 31 | success: (args, data) => { 32 | return JSON.stringify(data); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new ClientSideSecurityCommand(); 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | .idea 61 | *.sh 62 | settings.json 63 | akamai-appsec-*-linux-* 64 | akamai-appsec-*-mac-* 65 | akamai-appsec-*-windows-* 66 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "akamaicliappsec", 3 | "version": "3.3.0", 4 | "description": "Akamai Application Security via simple and easy to use CLI commands.", 5 | "repository": "https://github.com/akamai/cli-appsec", 6 | "license": "Apache-2.0", 7 | "engines": { 8 | "node": ">=16.0.0" 9 | }, 10 | "scripts": { 11 | "lint": "eslint src", 12 | "precommit": "lint-staged" 13 | }, 14 | "bin": { 15 | "appsec": "bin/akamai-appsec" 16 | }, 17 | "files": [ 18 | "bin/commands", 19 | "src", 20 | "templates" 21 | ], 22 | "dependencies": { 23 | "child-process-promise": "^2.2.1", 24 | "akamai-edgegrid": "^3.5.3", 25 | "figlet": "^1.5.0", 26 | "pino": "^4.10.4", 27 | "string-format": "^0.5.0", 28 | "sywac": "^1.2.0", 29 | "untildify": "^3.0.2", 30 | "yarn": "^1.22.10" 31 | }, 32 | "devDependencies": { 33 | "chai": "^4.3.6", 34 | "eslint": "^8.6.0", 35 | "fs": "0.0.1-security", 36 | "husky": "^0.14.3", 37 | "lint-staged": "^10.0.0", 38 | "prettier": "^1.6.1" 39 | }, 40 | "overrides": { 41 | "cross-spawn": "^7.0.3" 42 | }, 43 | "lint-staged": { 44 | "*.js": [ 45 | "prettier --single-quote --print-width 100 --write", 46 | "git add" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /bin/commands/customclientsequence.js: -------------------------------------------------------------------------------- 1 | let CustomClientSequence = require('../../src/customclientsequence').customClientSequence; 2 | let out = require('./lib/out'); 3 | 4 | class CustomClientSequenceCommand { 5 | constructor() { 6 | this.flags = 'custom-client-sequence'; 7 | this.desc = 'Display contents of custom client sequence.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }); 25 | } 26 | 27 | run(options) { 28 | out.print({ 29 | promise: new CustomClientSequence(options).getCustomClientSequence(), 30 | args: options, 31 | success: (args, data) => { 32 | return JSON.stringify(data); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new CustomClientSequenceCommand(); 39 | -------------------------------------------------------------------------------- /bin/commands/matchtarget.delete.js: -------------------------------------------------------------------------------- 1 | let out = require('./lib/out'); 2 | let MatchTarget = require('../../src/matchtarget').matchTarget; 3 | 4 | class DeleteMatchTargetCommand { 5 | constructor() { 6 | this.flags = 'delete-match-target'; 7 | this.desc = 'Delete a match target.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'The match target ID.' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | out.print({ 32 | promise: new MatchTarget(options).deleteMatchTarget(), 33 | args: options, 34 | success: (args, data) => { 35 | return data; 36 | } 37 | }); 38 | } 39 | } 40 | 41 | module.exports = new DeleteMatchTargetCommand(); 42 | -------------------------------------------------------------------------------- /bin/commands/challengeinjectionrules.js: -------------------------------------------------------------------------------- 1 | let ChallengeInjectionRules = require('../../src/challengeinjectionrules').challengeinjectionrules; 2 | let out = require('./lib/out'); 3 | 4 | class ChallengeInjectionRulesCommand { 5 | constructor() { 6 | this.flags = 'challenge-injection-rules'; 7 | this.desc = 'Display contents of challenge injection rules.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }); 25 | } 26 | 27 | run(options) { 28 | out.print({ 29 | promise: new ChallengeInjectionRules(options).getChallengeInjectionRules(), 30 | args: options, 31 | success: (args, data) => { 32 | return JSON.stringify(data); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new ChallengeInjectionRulesCommand(); 39 | -------------------------------------------------------------------------------- /src/bypassnl.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let fs = require('fs'); 5 | let untildify = require('untildify'); 6 | let Config = require('./configprovider').configProvider; 7 | let Version = require('./versionsprovider').versionProvider; 8 | let PolicyProvider = require('./policy').policy; 9 | 10 | class BypassNL { 11 | constructor(options) { 12 | this._config = new Config(options); 13 | this._options = options; 14 | this._version = new Version(options); 15 | this._policy = new PolicyProvider(options); 16 | } 17 | 18 | getBypassNetworkList() { 19 | let listUrl = URIs.BYPASS_NETWORK_LIST; 20 | 21 | return this._policy.readResource(listUrl, []); 22 | } 23 | 24 | updateBypassNetworkList() { 25 | if (fs.existsSync(this._options['file'])) { 26 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 27 | let data; 28 | try { 29 | data = JSON.parse(payload); 30 | } catch (err) { 31 | throw 'The input JSON is not valid'; 32 | } 33 | return this._policy.updateResource(URIs.BYPASS_NETWORK_LIST, [], data); 34 | } else { 35 | throw `The file does not exists: ${this._options['file']}`; 36 | } 37 | } 38 | } 39 | 40 | module.exports = { 41 | bypassnetworklist: BypassNL 42 | }; 43 | -------------------------------------------------------------------------------- /bin/commands/clone.js: -------------------------------------------------------------------------------- 1 | let Clone = require('../../src/clone').CloneHandler; 2 | let out = require('./lib/out'); 3 | 4 | class CloneCommand { 5 | constructor() { 6 | this.flags = 'clone'; 7 | this.desc = 'Clone a config version.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version number to clone. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .boolean('--rule-update', { 26 | desc: 27 | 'Specify whether the cloned config version should have updated rule-set. Defaults to false.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new Clone(options).clone(), 36 | args: options, 37 | success: (args, data) => { 38 | return data.version; 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new CloneCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/configs.js: -------------------------------------------------------------------------------- 1 | let out = require('./lib/out'); 2 | let Config = require('../../src/configprovider').configProvider; 3 | 4 | const objectType = 'configurations'; 5 | 6 | class ConfigsCommand { 7 | constructor() { 8 | this.flags = 'configs'; 9 | this.desc = 'List all available configurations.'; 10 | this.run = this.run.bind(this); 11 | this.setup = this.setup.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .boolean('--include-hostnames', { 17 | desc: 'Specify whether to include staging and production hostnames. Defaults to false.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .boolean('--include-contract-group', { 22 | desc: 'Specify whether to include contract and group ID. Defaults to false.', 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | 28 | run(options) { 29 | out.print({ 30 | promise: new Config(options).configs(), 31 | args: options, 32 | objectType, 33 | success: (args, data) => { 34 | let str = []; 35 | data[objectType].forEach(config => { 36 | str.push(config.id); 37 | }); 38 | return str.join(require('os').EOL); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new ConfigsCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/customrule.modify.js: -------------------------------------------------------------------------------- 1 | let CRB = require('../../src/crb').CRBHandler; 2 | let out = require('./lib/out'); 3 | 4 | class ModifyCustomRuleCommand { 5 | constructor() { 6 | this.flags = 'modify-custom-rule'; 7 | this.desc = 'Update existing custom rule.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .usage('Usage: akamai-appsec modify-custom-rule --custom-rule --file [options]') 15 | .number('--custom-rule ', { 16 | desc: 'Custom rule ID.', 17 | group: 'Required:', 18 | required: true 19 | }) 20 | .file('--file ', { 21 | desc: 'File with JSON rules', 22 | group: 'Required:', 23 | mustExist: true, 24 | required: true 25 | }) 26 | .number('--config ', { 27 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new CRB(options).updateRule(), 36 | args: options, 37 | success: (args, data) => { 38 | return data.id; 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new ModifyCustomRuleCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/config.rename.js: -------------------------------------------------------------------------------- 1 | let Config = require('../../src/configprovider').configProvider; 2 | let out = require('./lib/out'); 3 | 4 | class RenameConfigCommand { 5 | constructor() { 6 | this.flags = 'rename-config'; 7 | this.desc = 'Rename a security config.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .usage('Usage: akamai-appsec rename-config --name [options]') 15 | .string('--name ', { 16 | desc: 'Name of the security config.', 17 | group: 'Required:', 18 | required: true 19 | }) 20 | .number('--config ', { 21 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--description ', { 26 | desc: 'Description of the security config.', 27 | group: 'Optional:', 28 | required: false 29 | }); 30 | } 31 | 32 | run(options) { 33 | //get args 34 | out.print({ 35 | promise: new Config(options).renameConfig(), 36 | args: options, 37 | success: (args, data) => { 38 | return data; 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new RenameConfigCommand(); 45 | -------------------------------------------------------------------------------- /src/custombotcategoryitemsequence.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Version = require('./versionsprovider').versionProvider; 7 | 8 | class CustomBotCategoryItemSequence { 9 | constructor(options) { 10 | this._options = options; 11 | this._version = new Version(options); 12 | } 13 | 14 | getCustomBotCategoryItemSequence() { 15 | return this._version.readResource(URIs.CUSTOM_BOT_CATEGORY_ITEM_SEQUENCE, [ 16 | this._options['category-id'] 17 | ]); 18 | } 19 | 20 | updateCustomBotCategoryItemSequence() { 21 | if (fs.existsSync(untildify(this._options['file']))) { 22 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 23 | let data; 24 | try { 25 | data = JSON.parse(payload); 26 | } catch (err) { 27 | throw 'The input JSON is not valid'; 28 | } 29 | return this._version.updateResource( 30 | URIs.CUSTOM_BOT_CATEGORY_ITEM_SEQUENCE, 31 | [this._options['category-id']], 32 | data 33 | ); 34 | } else { 35 | throw `The file does not exists: ${this._options['file']}`; 36 | } 37 | } 38 | } 39 | 40 | module.exports = { 41 | custombotcategoryitemsequence: CustomBotCategoryItemSequence 42 | }; 43 | -------------------------------------------------------------------------------- /bin/commands/custombotcategorysequence.js: -------------------------------------------------------------------------------- 1 | let CustomBotCategorySequence = require('../../src/custombotcategorysequence') 2 | .custombotcategorysequence; 3 | let out = require('./lib/out'); 4 | 5 | class CustomBotCategorySequenceCommand { 6 | constructor() { 7 | this.flags = 'custom-bot-category-sequence'; 8 | this.desc = 'Display contents of custom bot category sequence.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) { 14 | sywac 15 | .number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }) 20 | .string('--version ', { 21 | desc: 22 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | 28 | run(options) { 29 | out.print({ 30 | promise: new CustomBotCategorySequence(options).getCustomBotCategorySequence(), 31 | args: options, 32 | success: (args, data) => { 33 | return JSON.stringify(data); 34 | } 35 | }); 36 | } 37 | } 38 | 39 | module.exports = new CustomBotCategorySequenceCommand(); 40 | -------------------------------------------------------------------------------- /bin/commands/customrule.js: -------------------------------------------------------------------------------- 1 | let CRB = require('../../src/crb').CRBHandler; 2 | let out = require('./lib/out'); 3 | 4 | class CustomRuleCommand { 5 | constructor() { 6 | this.flags = 'custom-rule'; 7 | this.desc = 'Display contents of custom rule.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .usage('Usage: akamai-appsec custom-rule --custom-rule [options]') 15 | .number('--custom-rule ', { 16 | desc: 'Custom rule ID.', 17 | group: 'Required:', 18 | required: true 19 | }) 20 | .number('--config ', { 21 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 22 | group: 'Optional:', 23 | required: false 24 | }); 25 | } 26 | 27 | run(options) { 28 | //if custom-rule id is provided without the parameter name, try to recognize it 29 | if (!options['custom-rule'] && options._ && !isNaN(options._[0])) { 30 | options['custom-rule'] = options._[0]; 31 | } 32 | out.print({ 33 | promise: new CRB(options).getRule(), 34 | args: options, 35 | success: (args, data) => { 36 | return JSON.stringify(data); 37 | } 38 | }); 39 | } 40 | } 41 | 42 | module.exports = new CustomRuleCommand(); 43 | -------------------------------------------------------------------------------- /bin/commands/policies.js: -------------------------------------------------------------------------------- 1 | let out = require('./lib/out'); 2 | let Policy = require('../../src/policy').policy; 3 | 4 | const objectType = 'policies'; 5 | 6 | class PoliciesCommand { 7 | constructor() { 8 | this.flags = 'policies'; 9 | this.desc = 'List all security policies.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }); 27 | } 28 | 29 | run(options) { 30 | out.print({ 31 | promise: new Policy(options).policies(), 32 | args: options, 33 | objectType, 34 | success: (args, data) => { 35 | let s = []; 36 | data[objectType].forEach(policy => { 37 | s.push(policy.policyId); 38 | }); 39 | return s.join(require('os').EOL); 40 | } 41 | }); 42 | } 43 | } 44 | 45 | module.exports = new PoliciesCommand(); 46 | -------------------------------------------------------------------------------- /bin/commands/customdeny.delete.js: -------------------------------------------------------------------------------- 1 | let CustomDeny = require('../../src/customdeny').customdeny; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteCustomDenyCommand { 5 | constructor() { 6 | this.flags = 'delete-custom-deny'; 7 | this.desc = 'Delete a custom deny action.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Custom Deny ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.custom_deny_id = options['custom-deny-id']; 32 | 33 | out.print({ 34 | promise: new CustomDeny(options).deleteCustomdeny(), 35 | args: options, 36 | success: (args, data) => { 37 | return data; 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new DeleteCustomDenyCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/customdeny.js: -------------------------------------------------------------------------------- 1 | let CustomDeny = require('../../src/customdeny').customdeny; 2 | let out = require('./lib/out'); 3 | 4 | class CustomDenyCommand { 5 | constructor() { 6 | this.flags = 'custom-deny'; 7 | this.desc = 'Display contents of custom deny action.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Custom Deny ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.custom_deny_id = options['custom-deny-id']; 32 | 33 | out.print({ 34 | promise: new CustomDeny(options).getCustomdeny(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new CustomDenyCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/accountprotectionriskactions.js: -------------------------------------------------------------------------------- 1 | let AccountProtectionRiskActions = require('../../src/accountprotectionriskactions') 2 | .accountProtectionRiskAction; 3 | let out = require('./lib/out'); 4 | 5 | class GetAccountProtectionRiskActionsCommand { 6 | constructor() { 7 | this.flags = 'account-protection-risk-actions'; 8 | this.desc = 'Display allowed risk actions for account protected endpoints.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) { 14 | sywac 15 | .number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }) 20 | .string('--version ', { 21 | desc: 22 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | run(options) { 28 | out.print({ 29 | promise: new AccountProtectionRiskActions(options).getRiskActions(), 30 | args: options, 31 | success: (args, data) => { 32 | return JSON.stringify(data); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new GetAccountProtectionRiskActionsCommand(); 39 | -------------------------------------------------------------------------------- /src/botdetectionaction.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Policy = require('./policy').policy; 7 | 8 | class BotDetectionAction { 9 | constructor(options) { 10 | this._options = options; 11 | this._policy = new Policy(options); 12 | } 13 | 14 | getBotDetectionActionList() { 15 | return this._policy.readResource(URIs.BOT_DETECTION_ACTIONS, []); 16 | } 17 | 18 | getBotDetectionAction() { 19 | return this._policy.readResource(URIs.BOT_DETECTION_ACTION, [ 20 | this._options['bot_detection_id'] 21 | ]); 22 | } 23 | 24 | updateBotDetectionAction() { 25 | if (fs.existsSync(untildify(this._options['file']))) { 26 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 27 | let data; 28 | try { 29 | data = JSON.parse(payload); 30 | } catch (err) { 31 | throw 'The input JSON is not valid'; 32 | } 33 | return this._policy.updateResource( 34 | URIs.BOT_DETECTION_ACTION, 35 | [this._options['bot_detection_id']], 36 | data 37 | ); 38 | } else { 39 | throw `The file does not exists: ${this._options['file']}`; 40 | } 41 | } 42 | } 43 | 44 | module.exports = { 45 | botdetectionaction: BotDetectionAction 46 | }; 47 | -------------------------------------------------------------------------------- /bin/commands/apipiilearning.js: -------------------------------------------------------------------------------- 1 | let AdvancedSettings = require('../../src/advancedsettings').advancedsettings; 2 | let out = require('./lib/out'); 3 | 4 | class GetApiPiiLearningCommand { 5 | constructor() { 6 | this.flags = 'api-pii-learning'; 7 | this.desc = 'Display the API PII Learning settings.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }); 25 | } 26 | run(options) { 27 | out.print({ 28 | promise: new AdvancedSettings(options).getApiPiiLearning(), 29 | args: options, 30 | success: (args, data) => { 31 | let enablePiiLearning = data.enablePiiLearning; 32 | let str = []; 33 | str.push(enablePiiLearning); 34 | return str.join(require('os').EOL); 35 | } 36 | }); 37 | } 38 | } 39 | 40 | module.exports = new GetApiPiiLearningCommand(); 41 | -------------------------------------------------------------------------------- /bin/commands/customclient.delete.js: -------------------------------------------------------------------------------- 1 | let CustomClient = require('../../src/customclient').customclient; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteCustomClientCommand { 5 | constructor() { 6 | this.flags = 'delete-custom-client'; 7 | this.desc = 'Delete a custom client.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Custom Client ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.custom_client_id = options['custom-client-id']; 32 | 33 | out.print({ 34 | promise: new CustomClient(options).deleteCustomClient(), 35 | args: options, 36 | success: (args, data) => { 37 | return data; 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new DeleteCustomClientCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/customclient.js: -------------------------------------------------------------------------------- 1 | let CustomClient = require('../../src/customclient').customclient; 2 | let out = require('./lib/out'); 3 | 4 | class CustomClientCommand { 5 | constructor() { 6 | this.flags = 'custom-client'; 7 | this.desc = 'Display contents of custom client.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Custom Client ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.custom_client_id = options['custom-client-id']; 32 | 33 | out.print({ 34 | promise: new CustomClient(options).getCustomClient(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new CustomClientCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/challengeaction.js: -------------------------------------------------------------------------------- 1 | let ChallengeAction = require('../../src/challengeaction').challengeaction; 2 | let out = require('./lib/out'); 3 | 4 | class ChallengeActionCommand { 5 | constructor() { 6 | this.flags = 'challenge-action'; 7 | this.desc = 'Display contents of challenge action.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Challenge Action ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.action_id = options['action-id']; 32 | 33 | out.print({ 34 | promise: new ChallengeAction(options).getChallengeAction(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new ChallengeActionCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/apipiilearning.enable.js: -------------------------------------------------------------------------------- 1 | let AdvancedSettings = require('../../src/advancedsettings').advancedsettings; 2 | let out = require('./lib/out'); 3 | 4 | class EnableApiPiiLearningCommand { 5 | constructor() { 6 | this.flags = 'enable-api-pii-learning'; 7 | this.desc = 'Enable API PII Learning setting.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }); 25 | } 26 | run(options) { 27 | out.print({ 28 | promise: new AdvancedSettings(options).updateApiPiiLearning(true), 29 | args: options, 30 | success: (args, data) => { 31 | let enablePiiLearning = data.enablePiiLearning; 32 | let str = []; 33 | str.push(enablePiiLearning); 34 | return str.join(require('os').EOL); 35 | } 36 | }); 37 | } 38 | } 39 | 40 | module.exports = new EnableApiPiiLearningCommand(); 41 | -------------------------------------------------------------------------------- /bin/commands/challengeaction.delete.js: -------------------------------------------------------------------------------- 1 | let ChallengeAction = require('../../src/challengeaction').challengeaction; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteChallengeActionCommand { 5 | constructor() { 6 | this.flags = 'delete-challenge-action'; 7 | this.desc = 'Delete a challenge action.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Challenge Action ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.action_id = options['action-id']; 32 | 33 | out.print({ 34 | promise: new ChallengeAction(options).deleteChallengeAction(), 35 | args: options, 36 | success: (args, data) => { 37 | return data; 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new DeleteChallengeActionCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/accountprotectionuserallowlistid.js: -------------------------------------------------------------------------------- 1 | let AccountProtectionAdvancedSettings = require('../../src/accountprotectionadvancedsettings') 2 | .accountProtectionAdvancedSettings; 3 | let out = require('./lib/out'); 4 | 5 | class GetAccountProtectionUserAllowListIdCommand { 6 | constructor() { 7 | this.flags = 'account-protection-user-allow-list-id'; 8 | this.desc = 'Display user allow list id for account protection.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) { 14 | sywac 15 | .number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }) 20 | .string('--version ', { 21 | desc: 22 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | run(options) { 28 | out.print({ 29 | promise: new AccountProtectionAdvancedSettings(options).getUserAllowListId(), 30 | args: options, 31 | success: (args, data) => { 32 | return JSON.stringify(data); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new GetAccountProtectionUserAllowListIdCommand(); 39 | -------------------------------------------------------------------------------- /bin/commands/apipiilearning.disable.js: -------------------------------------------------------------------------------- 1 | let AdvancedSettings = require('../../src/advancedsettings').advancedsettings; 2 | let out = require('./lib/out'); 3 | 4 | class DisableApiPiiLearningCommand { 5 | constructor() { 6 | this.flags = 'disable-api-pii-learning'; 7 | this.desc = 'Disable API PII Learning setting.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }); 25 | } 26 | run(options) { 27 | out.print({ 28 | promise: new AdvancedSettings(options).updateApiPiiLearning(false), 29 | args: options, 30 | success: (args, data) => { 31 | let enablePiiLearning = data.enablePiiLearning; 32 | let str = []; 33 | str.push(enablePiiLearning); 34 | return str.join(require('os').EOL); 35 | } 36 | }); 37 | } 38 | } 39 | 40 | module.exports = new DisableApiPiiLearningCommand(); 41 | -------------------------------------------------------------------------------- /bin/commands/ratepolicies.js: -------------------------------------------------------------------------------- 1 | let RatePolicy = require('../../src/ratepolicy').ratePolicy; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'ratePolicies'; 5 | class ListRatePoliciesCommand { 6 | constructor() { 7 | this.flags = 'rate-policies'; 8 | this.desc = 'List all rate policies.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) { 14 | sywac 15 | .number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }) 20 | .string('--version ', { 21 | desc: 22 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | run(options) { 28 | out.print({ 29 | promise: new RatePolicy(options).getAllRatePolicies(), 30 | args: options, 31 | objectType, 32 | success: (args, data) => { 33 | let str = []; 34 | data[objectType].forEach(ratePolicy => { 35 | str.push(ratePolicy.id); 36 | }); 37 | return str.join(require('os').EOL); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new ListRatePoliciesCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/customdenyaction.js: -------------------------------------------------------------------------------- 1 | let CustomDenyAction = require('../../src/customdenyaction').customdenyaction; 2 | let out = require('./lib/out'); 3 | 4 | class CustomDenyActionCommand { 5 | constructor() { 6 | this.flags = 'custom-deny-action'; 7 | this.desc = 'Display contents of custom deny action.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Custom Deny Action ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.action_id = options['action-id']; 32 | 33 | out.print({ 34 | promise: new CustomDenyAction(options).getCustomDenyAction(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new CustomDenyActionCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/transactionalendpointprotection.js: -------------------------------------------------------------------------------- 1 | let TransactionalEndpointProtection = require('../../src/transactionalendpointprotection') 2 | .transactionalendpointprotection; 3 | let out = require('./lib/out'); 4 | 5 | class TransactionalEndpointProtectionCommand { 6 | constructor() { 7 | this.flags = 'transactional-endpoint-protection'; 8 | this.desc = 'Display contents of transactional endpoint protection.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) { 14 | sywac 15 | .number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }) 20 | .string('--version ', { 21 | desc: 22 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | 28 | run(options) { 29 | out.print({ 30 | promise: new TransactionalEndpointProtection(options).getTransactionalEndpointProtection(), 31 | args: options, 32 | success: (args, data) => { 33 | return JSON.stringify(data); 34 | } 35 | }); 36 | } 37 | } 38 | 39 | module.exports = new TransactionalEndpointProtectionCommand(); 40 | -------------------------------------------------------------------------------- /src/akamaibotcategoryaction.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Policy = require('./policy').policy; 7 | 8 | class AkamaiBotCategoryAction { 9 | constructor(options) { 10 | this._options = options; 11 | this._policy = new Policy(options); 12 | } 13 | 14 | getAkamaiBotCategoryActionList() { 15 | return this._policy.readResource(URIs.AKAMAI_BOT_CATEGORY_ACTIONS, []); 16 | } 17 | 18 | getAkamaiBotCategoryAction() { 19 | return this._policy.readResource(URIs.AKAMAI_BOT_CATEGORY_ACTION, [ 20 | this._options['category_id'] 21 | ]); 22 | } 23 | 24 | updateAkamaiBotCategoryAction() { 25 | if (fs.existsSync(untildify(this._options['file']))) { 26 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 27 | let data; 28 | try { 29 | data = JSON.parse(payload); 30 | } catch (err) { 31 | throw 'The input JSON is not valid'; 32 | } 33 | return this._policy.updateResource( 34 | URIs.AKAMAI_BOT_CATEGORY_ACTION, 35 | [this._options['category_id']], 36 | data 37 | ); 38 | } else { 39 | throw `The file does not exists: ${this._options['file']}`; 40 | } 41 | } 42 | } 43 | 44 | module.exports = { 45 | akamaibotcategoryaction: AkamaiBotCategoryAction 46 | }; 47 | -------------------------------------------------------------------------------- /src/custombotcategoryaction.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const untildify = require('untildify'); 4 | let fs = require('fs'); 5 | let URIs = require('./constants').URIS; 6 | let Policy = require('./policy').policy; 7 | 8 | class CustomBotCategoryAction { 9 | constructor(options) { 10 | this._options = options; 11 | this._policy = new Policy(options); 12 | } 13 | 14 | getCustomBotCategoryActionList() { 15 | return this._policy.readResource(URIs.CUSTOM_BOT_CATEGORY_ACTIONS, []); 16 | } 17 | 18 | getCustomBotCategoryAction() { 19 | return this._policy.readResource(URIs.CUSTOM_BOT_CATEGORY_ACTION, [ 20 | this._options['category_id'] 21 | ]); 22 | } 23 | 24 | updateCustomBotCategoryAction() { 25 | if (fs.existsSync(untildify(this._options['file']))) { 26 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 27 | let data; 28 | try { 29 | data = JSON.parse(payload); 30 | } catch (err) { 31 | throw 'The input JSON is not valid'; 32 | } 33 | return this._policy.updateResource( 34 | URIs.CUSTOM_BOT_CATEGORY_ACTION, 35 | [this._options['category_id']], 36 | data 37 | ); 38 | } else { 39 | throw `The file does not exists: ${this._options['file']}`; 40 | } 41 | } 42 | } 43 | 44 | module.exports = { 45 | custombotcategoryaction: CustomBotCategoryAction 46 | }; 47 | -------------------------------------------------------------------------------- /bin/commands/customdenyaction.delete.js: -------------------------------------------------------------------------------- 1 | let CustomDenyAction = require('../../src/customdenyaction').customdenyaction; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteCustomDenyActionCommand { 5 | constructor() { 6 | this.flags = 'delete-custom-deny-action'; 7 | this.desc = 'Delete a custom deny action.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Custom Deny Action ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.action_id = options['action-id']; 32 | 33 | out.print({ 34 | promise: new CustomDenyAction(options).deleteCustomDenyAction(), 35 | args: options, 36 | success: (args, data) => { 37 | return data; 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new DeleteCustomDenyActionCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/mode.js: -------------------------------------------------------------------------------- 1 | let Mode = require('../../src/mode').mode; 2 | let out = require('./lib/out'); 3 | 4 | class GetModeCommand { 5 | constructor() { 6 | this.flags = 'mode'; 7 | this.desc = 'Display the WAF Mode.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new Mode(options).getMode(), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new GetModeCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/conditionalaction.delete.js: -------------------------------------------------------------------------------- 1 | let ConditionalAction = require('../../src/conditionalaction').conditionalaction; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteConditionalActionCommand { 5 | constructor() { 6 | this.flags = 'delete-conditional-action'; 7 | this.desc = 'Delete a conditional action.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Conditional Action ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.action_id = options['action-id']; 32 | 33 | out.print({ 34 | promise: new ConditionalAction(options).deleteConditionalAction(), 35 | args: options, 36 | success: (args, data) => { 37 | return data; 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new DeleteConditionalActionCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/conditionalaction.js: -------------------------------------------------------------------------------- 1 | let ConditionalAction = require('../../src/conditionalaction').conditionalaction; 2 | let out = require('./lib/out'); 3 | 4 | class ConditionalActionCommand { 5 | constructor() { 6 | this.flags = 'conditional-action'; 7 | this.desc = 'Display contents of conditional action.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Conditional Action ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.action_id = options['action-id']; 32 | 33 | out.print({ 34 | promise: new ConditionalAction(options).getConditionalAction(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new ConditionalActionCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/accountprotectionuserallowlistid.delete.js: -------------------------------------------------------------------------------- 1 | let AccountProtectionAdvancedSettings = require('../../src/accountprotectionadvancedsettings') 2 | .accountProtectionAdvancedSettings; 3 | let out = require('./lib/out'); 4 | 5 | class DeleteAccountProtectionUserAllowListIdCommand { 6 | constructor() { 7 | this.flags = 'delete-account-protection-user-allow-list-id'; 8 | this.desc = 'Delete user allow list id for account protection.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) { 14 | sywac 15 | .number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }) 20 | .string('--version ', { 21 | desc: 22 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | run(options) { 28 | out.print({ 29 | promise: new AccountProtectionAdvancedSettings(options).deleteUserAllowListId(), 30 | args: options, 31 | success: (args, data) => { 32 | return JSON.stringify(data); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new DeleteAccountProtectionUserAllowListIdCommand(); 39 | -------------------------------------------------------------------------------- /bin/commands/versionnotes.modify.js: -------------------------------------------------------------------------------- 1 | let VersionNotes = require('../../src/versionnotes').versionNotes; 2 | let out = require('./lib/out'); 3 | 4 | class ModifyVersionNotesCommand { 5 | constructor() { 6 | this.flags = 'modify-version-notes'; 7 | this.desc = 'Update the version notes.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Options:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Options:', 23 | required: false 24 | }) 25 | .string('--notes ', { 26 | desc: 'The version notes, if left empty, it will erase the current version notes.', 27 | group: 'Options:', 28 | required: false 29 | }); 30 | } 31 | run(options) { 32 | out.print({ 33 | promise: new VersionNotes(options).updateVersionNotes(), 34 | args: options, 35 | success: (args, data) => { 36 | return data.notes; 37 | } 38 | }); 39 | } 40 | } 41 | 42 | module.exports = new ModifyVersionNotesCommand(); 43 | -------------------------------------------------------------------------------- /bin/commands/custombotcategory.delete.js: -------------------------------------------------------------------------------- 1 | let CustomBotCategory = require('../../src/custombotcategory').custombotcategory; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteCustomBotCategoryCommand { 5 | constructor() { 6 | this.flags = 'delete-custom-bot-category'; 7 | this.desc = 'Delete a custom bot category.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Custom Bot Category ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.category_id = options['category-id']; 32 | 33 | out.print({ 34 | promise: new CustomBotCategory(options).deleteCustomBotCategory(), 35 | args: options, 36 | success: (args, data) => { 37 | return data; 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new DeleteCustomBotCategoryCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/custombotcategory.js: -------------------------------------------------------------------------------- 1 | let CustomBotCategory = require('../../src/custombotcategory').custombotcategory; 2 | let out = require('./lib/out'); 3 | 4 | class CustomBotCategoryCommand { 5 | constructor() { 6 | this.flags = 'custom-bot-category'; 7 | this.desc = 'Display contents of custom bot category.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Custom Bot Category ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.category_id = options['category-id']; 32 | 33 | out.print({ 34 | promise: new CustomBotCategory(options).getCustomBotCategory(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new CustomBotCategoryCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/customclientlist.js: -------------------------------------------------------------------------------- 1 | let CustomClient = require('../../src/customclient').customclient; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'customClients'; 5 | 6 | class ListCustomClientCommand { 7 | constructor() { 8 | this.flags = 'custom-client-list'; 9 | this.desc = 'List all custom client.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }); 27 | } 28 | run(options) { 29 | out.print({ 30 | promise: new CustomClient(options).getCustomClientList(), 31 | args: options, 32 | objectType, 33 | success: (args, data) => { 34 | let str = []; 35 | data[objectType].forEach(action => { 36 | str.push(action.customClientId); 37 | }); 38 | return str.join(require('os').EOL); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new ListCustomClientCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/botendpointcoveragereportconfigversion.js: -------------------------------------------------------------------------------- 1 | let BotEndpointCoverageReport = require('../../src/botendpointcoveragereport') 2 | .botendpointcoveragereport; 3 | let out = require('./lib/out'); 4 | 5 | class BotEndpointCoverageReportConfigVersionCommand { 6 | constructor() { 7 | this.flags = 'bot-endpoint-coverage-report-config-version'; 8 | this.desc = 'Display contents of bot endpoint coverage report - config version.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) { 14 | sywac 15 | .number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }) 20 | .string('--version ', { 21 | desc: 22 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | 28 | run(options) { 29 | out.print({ 30 | promise: new BotEndpointCoverageReport(options).getBotEndpointCoverageReportConfigVersion(), 31 | args: options, 32 | success: (args, data) => { 33 | return JSON.stringify(data); 34 | } 35 | }); 36 | } 37 | } 38 | 39 | module.exports = new BotEndpointCoverageReportConfigVersionCommand(); 40 | -------------------------------------------------------------------------------- /bin/commands/ratepolicy.delete.js: -------------------------------------------------------------------------------- 1 | let RatePolicy = require('../../src/ratepolicy').ratePolicy; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteRatePolicyCommand { 5 | constructor() { 6 | this.flags = 'delete-rate-policy'; 7 | this.desc = 'Delete a rate policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .usage('Usage: akamai-appsec delete-rate-policy --rate-policy [options]') 15 | .number('--rate-policy ', { 16 | desc: 'Rate Policy ID.', 17 | group: 'Required:', 18 | required: true 19 | }) 20 | .number('--config ', { 21 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--version ', { 26 | desc: 27 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new RatePolicy(options).deleteRatePolicy(), 36 | args: options, 37 | success: (args, data) => { 38 | return data; 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new DeleteRatePolicyCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/mode.set.js: -------------------------------------------------------------------------------- 1 | let Mode = require('../../src/mode').mode; 2 | let out = require('./lib/out'); 3 | 4 | class SetModeCommand { 5 | constructor() { 6 | this.flags = 'set-mode'; 7 | this.desc = 'Set the WAF Mode.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'The mode to be set to. Supported values are ASE_AUTO, ASE_MANUAL, AAG, KRS' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }) 28 | .string('--policy ', { 29 | desc: 'Security Policy ID.', 30 | group: 'Optional:', 31 | required: false 32 | }); 33 | } 34 | 35 | run(options) { 36 | out.print({ 37 | promise: new Mode(options).setMode(), 38 | args: options, 39 | success: (args, data) => { 40 | return JSON.stringify(data); 41 | } 42 | }); 43 | } 44 | } 45 | 46 | module.exports = new SetModeCommand(); 47 | -------------------------------------------------------------------------------- /bin/commands/customdefinedbot.js: -------------------------------------------------------------------------------- 1 | let CustomDefinedBot = require('../../src/customdefinedbot').customdefinedbot; 2 | let out = require('./lib/out'); 3 | 4 | class CustomDefinedBotCommand { 5 | constructor() { 6 | this.flags = 'custom-defined-bot'; 7 | this.desc = 'Display contents of custom defined bot.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Custom Defined Bot ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.custom_defined_bot_id = options['custom-defined-bot-id']; 32 | 33 | out.print({ 34 | promise: new CustomDefinedBot(options).getCustomDefinedBot(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new CustomDefinedBotCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/customdefinedbot.delete.js: -------------------------------------------------------------------------------- 1 | let CustomDefinedBot = require('../../src/customdefinedbot').customdefinedbot; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteCustomDefinedBotCommand { 5 | constructor() { 6 | this.flags = 'delete-custom-defined-bot'; 7 | this.desc = 'Delete a custom defined bot.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Custom Defined Bot ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.custom_defined_bot_id = options['custom-defined-bot-id']; 32 | 33 | out.print({ 34 | promise: new CustomDefinedBot(options).deleteCustomDefinedBot(), 35 | args: options, 36 | success: (args, data) => { 37 | return data; 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new DeleteCustomDefinedBotCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/customdefinedbotlist.js: -------------------------------------------------------------------------------- 1 | let CustomDefinedBot = require('../../src/customdefinedbot').customdefinedbot; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'bots'; 5 | 6 | class ListCustomDefinedBotCommand { 7 | constructor() { 8 | this.flags = 'custom-defined-bot-list'; 9 | this.desc = 'List all custom defined bot.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }); 27 | } 28 | run(options) { 29 | out.print({ 30 | promise: new CustomDefinedBot(options).getCustomDefinedBotList(), 31 | args: options, 32 | objectType, 33 | success: (args, data) => { 34 | let str = []; 35 | data[objectType].forEach(action => { 36 | str.push(action.botId); 37 | }); 38 | return str.join(require('os').EOL); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new ListCustomDefinedBotCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/servealternateaction.delete.js: -------------------------------------------------------------------------------- 1 | let ServeAlternateAction = require('../../src/servealternateaction').servealternateaction; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteServeAlternateActionCommand { 5 | constructor() { 6 | this.flags = 'delete-serve-alternate-action'; 7 | this.desc = 'Delete a serve alternate action.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Serve Alternate Action ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.action_id = options['action-id']; 32 | 33 | out.print({ 34 | promise: new ServeAlternateAction(options).deleteServeAlternateAction(), 35 | args: options, 36 | success: (args, data) => { 37 | return data; 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new DeleteServeAlternateActionCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/servealternateaction.js: -------------------------------------------------------------------------------- 1 | let ServeAlternateAction = require('../../src/servealternateaction').servealternateaction; 2 | let out = require('./lib/out'); 3 | 4 | class ServeAlternateActionCommand { 5 | constructor() { 6 | this.flags = 'serve-alternate-action'; 7 | this.desc = 'Display contents of serve alternate action.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Serve Alternate Action ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | options.action_id = options['action-id']; 32 | 33 | out.print({ 34 | promise: new ServeAlternateAction(options).getServeAlternateAction(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new ServeAlternateActionCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/slowpost.js: -------------------------------------------------------------------------------- 1 | let SlowPost = require('../../src/slowpost').slowPost; 2 | let out = require('./lib/out'); 3 | 4 | class SlowPostCommand { 5 | constructor() { 6 | this.flags = 'slow-post'; 7 | this.desc = 'Display contents of slow post.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new SlowPost(options).getSlowPost(), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new SlowPostCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/challengeactionlist.js: -------------------------------------------------------------------------------- 1 | let ChallengeAction = require('../../src/challengeaction').challengeaction; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'challengeActions'; 5 | 6 | class ListChallengeActionCommand { 7 | constructor() { 8 | this.flags = 'challenge-action-list'; 9 | this.desc = 'List all challenge action.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }); 27 | } 28 | run(options) { 29 | out.print({ 30 | promise: new ChallengeAction(options).getChallengeActionList(), 31 | args: options, 32 | objectType, 33 | success: (args, data) => { 34 | let str = []; 35 | data[objectType].forEach(action => { 36 | str.push(action.actionId); 37 | }); 38 | return str.join(require('os').EOL); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new ListChallengeActionCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/malwarepolicies.js: -------------------------------------------------------------------------------- 1 | let MalwareProtection = require('../../src/malwareprotection').malwareProtection; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'malwarePolicies'; 5 | class ListMalwarePoliciesCommand { 6 | constructor() { 7 | this.flags = 'malware-policies'; 8 | this.desc = 'List all malware policies.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) { 14 | sywac 15 | .number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }) 20 | .string('--version ', { 21 | desc: 22 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | run(options) { 28 | out.print({ 29 | promise: new MalwareProtection(options).getAllMalwarePolicies(), 30 | args: options, 31 | objectType, 32 | success: (args, data) => { 33 | let str = []; 34 | data[objectType].forEach(malwarePolicy => { 35 | str.push(malwarePolicy.id); 36 | }); 37 | return str.join(require('os').EOL); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new ListMalwarePoliciesCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/responseactionslist.js: -------------------------------------------------------------------------------- 1 | let ResponseActions = require('../../src/responseactions').responseactions; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'responseActions'; 5 | 6 | class ListResponseActionsCommand { 7 | constructor() { 8 | this.flags = 'response-actions-list'; 9 | this.desc = 'List all response actions.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }); 27 | } 28 | run(options) { 29 | out.print({ 30 | promise: new ResponseActions(options).getResponseActionsList(), 31 | args: options, 32 | objectType, 33 | success: (args, data) => { 34 | let str = []; 35 | data[objectType].forEach(action => { 36 | str.push(action.actionId); 37 | }); 38 | return str.join(require('os').EOL); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new ListResponseActionsCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/rule.upgradedetails.js: -------------------------------------------------------------------------------- 1 | let Rules = require('../../src/rules').rules; 2 | let out = require('./lib/out'); 3 | 4 | class RuleActionsCommand { 5 | constructor() { 6 | this.flags = 'upgrade-details'; 7 | this.desc = 'Display rules updates.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | run(options) { 33 | out.print({ 34 | promise: new Rules(options).getUpgradeDetails(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new RuleActionsCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/eval.stop.js: -------------------------------------------------------------------------------- 1 | let EvalRules = require('../../src/evalrules').evalrules; 2 | let out = require('./lib/out'); 3 | 4 | class EnableEvalRuleCommand { 5 | constructor() { 6 | this.flags = 'end-eval'; 7 | this.desc = 'Stop evaluation in a policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new EvalRules(options).stopEval(), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new EnableEvalRuleCommand(); 45 | -------------------------------------------------------------------------------- /src/hostnamecoverage.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let Config = require('./configprovider').configProvider; 5 | let Version = require('./versionsprovider').versionProvider; 6 | let Edge = 7 | process.env.MOCK_AKA_SEC_API == 'true' ? require('../mock/edgeClient') : require('./edgeClient'); 8 | 9 | class HostnameCoverage { 10 | constructor(options) { 11 | this._edge = new Edge(options); 12 | this._config = new Config(options); 13 | this._options = options; 14 | this._version = new Version(options); 15 | } 16 | 17 | getHostnameCoverage() { 18 | if (this._options['match-target'] && this._options['overlapping']) { 19 | throw 'Cannot retrieve both the hostname coverage match targets and overlapping list at the same time.'; 20 | } else if (this._options['match-target'] || this._options['overlapping']) { 21 | if (!this._options['hostname']) { 22 | throw 'Hostname is required when retrieving hostname coverage match target or overlapping list.'; 23 | } 24 | return this._version.readResource( 25 | this._options['match-target'] 26 | ? URIs.HOSTNAME_COVERAGE_MATCH_TARGET 27 | : URIs.HOSTNAME_COVERAGE_OVERLAPPING, 28 | [this._options['hostname']] 29 | ); 30 | } else { 31 | return this._edge.get(URIs.HOSTNAME_COVERAGE); 32 | } 33 | } 34 | } 35 | 36 | module.exports = { 37 | hostnameCoverage: HostnameCoverage 38 | }; 39 | -------------------------------------------------------------------------------- /bin/commands/customdenyactionlist.js: -------------------------------------------------------------------------------- 1 | let CustomDenyAction = require('../../src/customdenyaction').customdenyaction; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'customDenyActions'; 5 | 6 | class ListCustomDenyActionCommand { 7 | constructor() { 8 | this.flags = 'custom-deny-action-list'; 9 | this.desc = 'List all custom deny action.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }); 27 | } 28 | run(options) { 29 | out.print({ 30 | promise: new CustomDenyAction(options).getCustomDenyActionList(), 31 | args: options, 32 | objectType, 33 | success: (args, data) => { 34 | let str = []; 35 | data[objectType].forEach(action => { 36 | str.push(action.actionId); 37 | }); 38 | return str.join(require('os').EOL); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new ListCustomDenyActionCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/accountprotectionuserriskresponsestrategy.js: -------------------------------------------------------------------------------- 1 | let AccountProtectionAdvancedSettings = require('../../src/accountprotectionadvancedsettings') 2 | .accountProtectionAdvancedSettings; 3 | let out = require('./lib/out'); 4 | 5 | class GetAccountProtectionUserRiskResponseStrategyCommand { 6 | constructor() { 7 | this.flags = 'account-protection-user-risk-response-strategy'; 8 | this.desc = 'Display account protected advanced settings for user risk response strategy.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) { 14 | sywac 15 | .number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }) 20 | .string('--version ', { 21 | desc: 22 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | run(options) { 28 | out.print({ 29 | promise: new AccountProtectionAdvancedSettings(options).getUserRiskResponseStrategy(), 30 | args: options, 31 | success: (args, data) => { 32 | return JSON.stringify(data); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | module.exports = new GetAccountProtectionUserRiskResponseStrategyCommand(); 39 | -------------------------------------------------------------------------------- /bin/commands/custombotcategorylist.js: -------------------------------------------------------------------------------- 1 | let CustomBotCategory = require('../../src/custombotcategory').custombotcategory; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'categories'; 5 | 6 | class ListCustomBotCategoryCommand { 7 | constructor() { 8 | this.flags = 'custom-bot-category-list'; 9 | this.desc = 'List all custom bot category.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }); 27 | } 28 | run(options) { 29 | out.print({ 30 | promise: new CustomBotCategory(options).getCustomBotCategoryList(), 31 | args: options, 32 | objectType, 33 | success: (args, data) => { 34 | let str = []; 35 | data[objectType].forEach(action => { 36 | str.push(action.categoryId); 37 | }); 38 | return str.join(require('os').EOL); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new ListCustomBotCategoryCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/reputationProfiles.js: -------------------------------------------------------------------------------- 1 | let ReputationProfile = require('../../src/reputationprofile').reputationProfile; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'reputationProfiles'; 5 | 6 | class ListReputationProfilesCommand { 7 | constructor() { 8 | this.flags = 'reputation-profiles'; 9 | this.desc = 'List all reputation profiles.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }); 27 | } 28 | run(options) { 29 | out.print({ 30 | promise: new ReputationProfile(options).getAllReputationProfiles(), 31 | args: options, 32 | objectType, 33 | success: (args, data) => { 34 | let str = []; 35 | data[objectType].forEach(profile => { 36 | str.push(profile.id); 37 | }); 38 | return str.join(require('os').EOL); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new ListReputationProfilesCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/conditionalactionlist.js: -------------------------------------------------------------------------------- 1 | let ConditionalAction = require('../../src/conditionalaction').conditionalaction; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'conditionalActions'; 5 | 6 | class ListConditionalActionCommand { 7 | constructor() { 8 | this.flags = 'conditional-action-list'; 9 | this.desc = 'List all conditional action.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }); 27 | } 28 | run(options) { 29 | out.print({ 30 | promise: new ConditionalAction(options).getConditionalActionList(), 31 | args: options, 32 | objectType, 33 | success: (args, data) => { 34 | let str = []; 35 | data[objectType].forEach(action => { 36 | str.push(action.actionId); 37 | }); 38 | return str.join(require('os').EOL); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new ListConditionalActionCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/eval.restart.js: -------------------------------------------------------------------------------- 1 | let EvalRules = require('../../src/evalrules').evalrules; 2 | let out = require('./lib/out'); 3 | 4 | class EnableEvalRuleCommand { 5 | constructor() { 6 | this.flags = 'restart-eval'; 7 | this.desc = 'Restart evaluation in a policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new EvalRules(options).restartEval(), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new EnableEvalRuleCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/eval.update.js: -------------------------------------------------------------------------------- 1 | let EvalRules = require('../../src/evalrules').evalrules; 2 | let out = require('./lib/out'); 3 | 4 | class EnableEvalRuleCommand { 5 | constructor() { 6 | this.flags = 'update-eval'; 7 | this.desc = 'Update the evaluation in a policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new EvalRules(options).updateEval(), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new EnableEvalRuleCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/slowpost.disable.js: -------------------------------------------------------------------------------- 1 | let SlowPost = require('../../src/slowpost').slowPost; 2 | let out = require('./lib/out'); 3 | 4 | class SlowPostCommand { 5 | constructor() { 6 | this.flags = 'disable-slow-post'; 7 | this.desc = 'Disable slow post on the policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new SlowPost(options).disableSlowPost(), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new SlowPostCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/threatintel.js: -------------------------------------------------------------------------------- 1 | let ThreatIntel = require('../../src/threatintel').threatIntel; 2 | let out = require('./lib/out'); 3 | 4 | class ThreatIntelCommand { 5 | constructor() { 6 | this.flags = 'threat-intel'; 7 | this.desc = 'Threat Intel setting for a policy'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | run(options) { 33 | out.print({ 34 | promise: new ThreatIntel(options).getThreatIntel(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new ThreatIntelCommand(); 44 | -------------------------------------------------------------------------------- /src/ipgeofirewall.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | let fs = require('fs'); 5 | let untildify = require('untildify'); 6 | let Config = require('./configprovider').configProvider; 7 | let Version = require('./versionsprovider').versionProvider; 8 | let PolicyProvider = require('./policy').policy; 9 | 10 | class IpGeoFirewall { 11 | constructor(options) { 12 | this._config = new Config(options); 13 | this._options = options; 14 | this._version = new Version(options); 15 | this._policyProvider = new PolicyProvider(options); 16 | } 17 | 18 | getIpGeoFirewall() { 19 | return this._policyProvider.policyId().then(policyId => { 20 | return this._version.readResource(URIs.IP_GEO_FIREWALL, [policyId]); 21 | }); 22 | } 23 | 24 | updateIpGeoFirewall() { 25 | if (fs.existsSync(this._options['file'])) { 26 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 27 | let data; 28 | try { 29 | data = JSON.parse(payload); 30 | } catch (err) { 31 | throw 'The input JSON is not valid'; 32 | } 33 | return this._policyProvider.policyId().then(policyId => { 34 | return this._version.updateResource(URIs.IP_GEO_FIREWALL, [policyId], data); 35 | }); 36 | } else { 37 | throw `The file does not exists: ${this._options['file']}`; 38 | } 39 | } 40 | } 41 | 42 | module.exports = { 43 | ipgeofirewall: IpGeoFirewall 44 | }; 45 | -------------------------------------------------------------------------------- /bin/commands/penaltybox.js: -------------------------------------------------------------------------------- 1 | let PenaltyBox = require('../../src/penaltybox').penaltyBox; 2 | let out = require('./lib/out'); 3 | 4 | class PenaltyBoxCommand { 5 | constructor() { 6 | this.flags = 'penalty-box'; 7 | this.desc = 'Display penalty box protections for a policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | run(options) { 33 | out.print({ 34 | promise: new PenaltyBox(options).getPenaltyBox(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new PenaltyBoxCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/securitypolicy.delete.js: -------------------------------------------------------------------------------- 1 | let SecurityPolicy = require('../../src/policy').policy; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteCustomRuleCommand { 5 | constructor() { 6 | this.flags = 'delete-security-policy'; 7 | this.desc = 'Delete a security policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new SecurityPolicy(options).deletePolicy(), 36 | args: options, 37 | success: (args, data) => { 38 | return data; 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new DeleteCustomRuleCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/eval.complete.js: -------------------------------------------------------------------------------- 1 | let EvalRules = require('../../src/evalrules').evalrules; 2 | let out = require('./lib/out'); 3 | 4 | class EnableEvalRuleCommand { 5 | constructor() { 6 | this.flags = 'complete-eval'; 7 | this.desc = 'Complete the evaluation in a policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new EvalRules(options).completeEval(), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new EnableEvalRuleCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/securitypolicy.js: -------------------------------------------------------------------------------- 1 | let SecurityPolicy = require('../../src/policy').policy; 2 | let out = require('./lib/out'); 3 | 4 | class SecurityPolicyCommand { 5 | constructor() { 6 | this.flags = 'security-policy'; 7 | this.desc = 'Display contents of security policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new SecurityPolicy(options).getPolicy(), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new SecurityPolicyCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/evalgroups.js: -------------------------------------------------------------------------------- 1 | let AttackGroups = require('../../src/evalgroups').attackGroups; 2 | let out = require('./lib/out'); 3 | 4 | class AttackGroupsCommand { 5 | constructor() { 6 | this.flags = 'eval-groups'; 7 | this.desc = 'Display eval attack groups and actions.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | run(options) { 33 | out.print({ 34 | promise: new AttackGroups(options).getAttackGroupActions(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new AttackGroupsCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/pragmaheader.js: -------------------------------------------------------------------------------- 1 | let AdvancedSettings = require('../../src/advancedsettings').advancedsettings; 2 | let out = require('./lib/out'); 3 | 4 | class PragmaHeaderCommand { 5 | constructor() { 6 | this.flags = 'pragma-header'; 7 | this.desc = 'Display Pragma Header settings'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | run(options) { 33 | out.print({ 34 | promise: new AdvancedSettings(options).getPragmaHeader(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new PragmaHeaderCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/requestbody.js: -------------------------------------------------------------------------------- 1 | let AdvancedSettings = require('../../src/advancedsettings').advancedsettings; 2 | let out = require('./lib/out'); 3 | 4 | class RequestBodyCommand { 5 | constructor() { 6 | this.flags = 'request-body'; 7 | this.desc = 'Display Request Body settings'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new AdvancedSettings(options).getRequestBody(), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new RequestBodyCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/penaltybox.disable.js: -------------------------------------------------------------------------------- 1 | let PenaltyBox = require('../../src/penaltybox').penaltyBox; 2 | let out = require('./lib/out'); 3 | 4 | class DisablePenaltyBoxCommand { 5 | constructor() { 6 | this.flags = 'disable-penalty-box'; 7 | this.desc = 'Disable penalty box on the policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | run(options) { 33 | out.print({ 34 | promise: new PenaltyBox(options).disablePenaltyBox(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new DisablePenaltyBoxCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/malwarepolicy.delete.js: -------------------------------------------------------------------------------- 1 | let MalwareProtection = require('../../src/malwareprotection').malwareProtection; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteMalwarePoliciesCommand { 5 | constructor() { 6 | this.flags = 'delete-malware-policy'; 7 | this.desc = 'Delete an existing malware policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .usage('Usage: akamai-appsec delete-malware-policy --malware-policy [options]') 15 | .number('--malware-policy ', { 16 | desc: 'Malware Policy ID.', 17 | group: 'Required:', 18 | required: true 19 | }) 20 | .number('--config ', { 21 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--version ', { 26 | desc: 27 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new MalwareProtection(options).deleteMalwarePolicy(), 36 | args: options, 37 | success: (args, data) => { 38 | return data; 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new DeleteMalwarePoliciesCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/rules.js: -------------------------------------------------------------------------------- 1 | let Rules = require('../../src/rules').rules; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'ruleActions'; 5 | 6 | class RuleActionsCommand { 7 | constructor() { 8 | this.flags = 'rule-actions'; 9 | this.desc = 'Display rules and actions.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }) 27 | .string('--policy ', { 28 | desc: 29 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 30 | group: 'Optional:', 31 | required: false 32 | }); 33 | } 34 | run(options) { 35 | out.print({ 36 | promise: new Rules(options).getRulesActions(), 37 | args: options, 38 | objectType, 39 | success: (args, data) => { 40 | return JSON.stringify(data); 41 | } 42 | }); 43 | } 44 | } 45 | 46 | module.exports = new RuleActionsCommand(); 47 | -------------------------------------------------------------------------------- /bin/commands/malwarepolicycontenttypes.js: -------------------------------------------------------------------------------- 1 | let MalwareProtection = require('../../src/malwareprotection').malwareProtection; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'malwareContentTypes'; 5 | class ListMalwareContentTypesCommand { 6 | constructor() { 7 | this.flags = 'malware-content-types'; 8 | this.desc = 'List all malware content types.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) { 14 | sywac 15 | .number('--config ', { 16 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 17 | group: 'Optional:', 18 | required: false 19 | }) 20 | .string('--version ', { 21 | desc: 22 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | run(options) { 28 | out.print({ 29 | promise: new MalwareProtection(options).getMalwarePolicyContentTypes(), 30 | args: options, 31 | objectType, 32 | success: (args, data) => { 33 | let str = []; 34 | data[objectType].forEach(malwarePolicyContentType => { 35 | str.push(malwarePolicyContentType); 36 | }); 37 | return str.join(require('os').EOL); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new ListMalwareContentTypesCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/servealternateactionlist.js: -------------------------------------------------------------------------------- 1 | let ServeAlternateAction = require('../../src/servealternateaction').servealternateaction; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'serveAlternateActions'; 5 | 6 | class ListServeAlternateActionCommand { 7 | constructor() { 8 | this.flags = 'serve-alternate-action-list'; 9 | this.desc = 'List all serve alternate action.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }); 27 | } 28 | run(options) { 29 | out.print({ 30 | promise: new ServeAlternateAction(options).getServeAlternateActionList(), 31 | args: options, 32 | objectType, 33 | success: (args, data) => { 34 | let str = []; 35 | data[objectType].forEach(action => { 36 | str.push(action.actionId); 37 | }); 38 | return str.join(require('os').EOL); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new ListServeAlternateActionCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/threatintel.disable.js: -------------------------------------------------------------------------------- 1 | let ThreatIntel = require('../../src/threatintel').threatIntel; 2 | let out = require('./lib/out'); 3 | 4 | class EnableThreatIntelCommand { 5 | constructor() { 6 | this.flags = 'disable-threat-intel'; 7 | this.desc = 'Disable Threat Intelligence.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new ThreatIntel(options).toggleThreatIntel("off"), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new EnableThreatIntelCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/threatintel.enable.js: -------------------------------------------------------------------------------- 1 | let ThreatIntel = require('../../src/threatintel').threatIntel; 2 | let out = require('./lib/out'); 3 | 4 | class EnableThreatIntelCommand { 5 | constructor() { 6 | this.flags = 'enable-threat-intel'; 7 | this.desc = 'Enable Threat Intelligence.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new ThreatIntel(options).toggleThreatIntel("on"), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new EnableThreatIntelCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/version.js: -------------------------------------------------------------------------------- 1 | let out = require('./lib/out'); 2 | let Version = require('../../src/versionsprovider').versionProvider; 3 | 4 | class VersionCommand { 5 | constructor() { 6 | this.flags = 'version'; 7 | this.desc = 'Read a config version.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 16 | "Configuration ID. If not provided, assumes there is only one configuration and chooses it. If there's more, an error is thrown.", 17 | group: 'Optional:', 18 | required: false 19 | }) 20 | .string('--version ', { 21 | desc: 22 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 23 | group: 'Optional:', 24 | required: false 25 | }); 26 | } 27 | 28 | run(options) { 29 | //if version is provided without the parameter name, try to recognize it 30 | if (!options.version && options._ && !isNaN(options._[0])) { 31 | options.version = options._[0]; 32 | } 33 | out.print({ 34 | promise: new Version(options).version(), 35 | args: options, 36 | success: (args, data) => { 37 | //we want the whole json irrespective of the json flag 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new VersionCommand(); 45 | -------------------------------------------------------------------------------- /src/siemsettings.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | //needed to pass files to PUT/POST 5 | let fs = require('fs'); 6 | //Ensures user can add paths like '~/foo' 7 | let untildify = require('untildify'); 8 | let Config = require('./configprovider').configProvider; 9 | let Version = require('./versionsprovider').versionProvider; 10 | let Edge = 11 | process.env.MOCK_AKA_SEC_API == 'true' ? require('../mock/edgeClient') : require('./edgeClient'); 12 | 13 | class SIEMSettings { 14 | constructor(options) { 15 | this._edge = new Edge(options); 16 | this._config = new Config(options); 17 | this._options = options; 18 | this._version = new Version(options); 19 | } 20 | 21 | getSIEMDefinitions() { 22 | return this._edge.get(URIs.SIEM_DEF_RESOURCE); 23 | } 24 | 25 | getSIEMSettings() { 26 | return this._version.readResource(URIs.SIEM_RESOURCE, []); 27 | } 28 | 29 | updateSIEMSettings() { 30 | if (fs.existsSync(this._options['file'])) { 31 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 32 | let data; 33 | try { 34 | data = JSON.parse(payload); 35 | } catch (err) { 36 | throw 'The input JSON is not valid'; 37 | } 38 | return this._version.updateResource(URIs.SIEM_RESOURCE, [], data); 39 | } else { 40 | throw `The file does not exists: ${this._options['file']}`; 41 | } 42 | } 43 | } 44 | 45 | module.exports = { 46 | siemSettings: SIEMSettings 47 | }; 48 | -------------------------------------------------------------------------------- /bin/commands/apiconstraint.js: -------------------------------------------------------------------------------- 1 | let ApiConstraint = require('../../src/apiconstraint').apiconstraint; 2 | let out = require('./lib/out'); 3 | 4 | class ApiConstraintCommand { 5 | constructor() { 6 | this.flags = 'api-request-constraints-action'; 7 | this.desc = 'Display API Request Constraint action.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | run(options) { 33 | out.print({ 34 | promise: new ApiConstraint(options).getApiConstraintAction(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new ApiConstraintCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/ipgeofirewall.js: -------------------------------------------------------------------------------- 1 | let IpGeoFirewall = require('../../src/ipgeofirewall').ipgeofirewall; 2 | let out = require('./lib/out'); 3 | 4 | class IpGeoFirewallCommand { 5 | constructor() { 6 | this.flags = 'ip-geo-firewall'; 7 | this.desc = 'Display the IP Geo Firewall network lists in a policy'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new IpGeoFirewall(options).getIpGeoFirewall(), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new IpGeoFirewallCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/accountprotectionadvancedsettingstep.js: -------------------------------------------------------------------------------- 1 | let AccountProtectionAdvancedSettings = require('../../src/accountprotectionadvancedsettings') 2 | .accountProtectionAdvancedSettings; 3 | let out = require('./lib/out'); 4 | 5 | // Deprecated 6 | class GetAccountProtectionTransactionEndpointProtectionCommand { 7 | constructor() { 8 | this.flags = 'account-protection-transactional-endpoint-protection'; 9 | this.desc = 10 | '[Deprecated] Display account protected advanced settings for transactional endpoints.'; 11 | this.setup = this.setup.bind(this); 12 | this.run = this.run.bind(this); 13 | } 14 | 15 | setup(sywac) { 16 | sywac 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | run(options) { 30 | out.print({ 31 | promise: new AccountProtectionAdvancedSettings(options).getTransactionalEndpointProtection(), 32 | args: options, 33 | success: (args, data) => { 34 | return JSON.stringify(data); 35 | } 36 | }); 37 | } 38 | } 39 | 40 | module.exports = new GetAccountProtectionTransactionEndpointProtectionCommand(); 41 | -------------------------------------------------------------------------------- /bin/commands/attackpayloadlogging.js: -------------------------------------------------------------------------------- 1 | let AdvancedSettings = require('../../src/advancedsettings').advancedsettings; 2 | let out = require('./lib/out'); 3 | 4 | class AttackPayloadLoggingCommand { 5 | constructor() { 6 | this.flags = 'attack-payload-logging'; 7 | this.desc = 'Display the Attack Payload Logging settings.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If provided, returns policy-level settings. If not provided, returns config-level settings.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new AdvancedSettings(options).getAttackPayloadLogging(), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new AttackPayloadLoggingCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/custombotcategoryitemsequence.js: -------------------------------------------------------------------------------- 1 | let CustomBotCategoryItemSequence = require('../../src/custombotcategoryitemsequence') 2 | .custombotcategoryitemsequence; 3 | let out = require('./lib/out'); 4 | class CustomBotCategoryItemSequenceCommand { 5 | constructor() { 6 | this.flags = 'custom-bot-category-item-sequence'; 7 | this.desc = 'Display contents of custom bot category item sequence.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'Custom Bot Category ID' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }); 28 | } 29 | 30 | run(options) { 31 | out.print({ 32 | promise: new CustomBotCategoryItemSequence(options).getCustomBotCategoryItemSequence(), 33 | args: options, 34 | success: (args, data) => { 35 | delete data.validation; 36 | return JSON.stringify(data); 37 | } 38 | }); 39 | } 40 | } 41 | 42 | module.exports = new CustomBotCategoryItemSequenceCommand(); 43 | -------------------------------------------------------------------------------- /bin/commands/evalpenaltybox.js: -------------------------------------------------------------------------------- 1 | let EvalPenaltyBox = require('../../src/evalpenaltybox').evalPenaltyBox; 2 | let out = require('./lib/out'); 3 | 4 | class EvalPenaltyBoxCommand { 5 | constructor() { 6 | this.flags = 'eval-penalty-box'; 7 | this.desc = 'Display evaluation penalty box protections for the policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | run(options) { 33 | out.print({ 34 | promise: new EvalPenaltyBox(options).getPenaltyBox(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new EvalPenaltyBoxCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/policyprotections.js: -------------------------------------------------------------------------------- 1 | let PolicyProtections = require('../../src/policyprotection').policyProtection; 2 | let out = require('./lib/out'); 3 | 4 | class PolicyProtectionsCommand { 5 | constructor() { 6 | this.flags = 'protections'; 7 | this.desc = 'Display contents of security policy protections.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | run(options) { 33 | out.print({ 34 | promise: new PolicyProtections(options).getProtections(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new PolicyProtectionsCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/reputationprofile.delete.js: -------------------------------------------------------------------------------- 1 | let ReputationProfile = require('../../src/reputationprofile').reputationProfile; 2 | let out = require('./lib/out'); 3 | 4 | class DeleteReputationProfileCommand { 5 | constructor() { 6 | this.flags = 'delete-reputation-profile'; 7 | this.desc = 'Delete a reputation profile.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .usage('Usage: akamai-appsec delete-reputation-profile --reputation-profile [options]') 15 | .number('--reputation-profile ', { 16 | desc: 'Reputation Profile ID.', 17 | group: 'Required:', 18 | required: true 19 | }) 20 | .number('--config ', { 21 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--version ', { 26 | desc: 27 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | 33 | run(options) { 34 | out.print({ 35 | promise: new ReputationProfile(options).deleteReputationProfile(), 36 | args: options, 37 | success: (args, data) => { 38 | return data; 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new DeleteReputationProfileCommand(); 45 | -------------------------------------------------------------------------------- /bin/commands/evalpenaltybox.disable.js: -------------------------------------------------------------------------------- 1 | let EvalPenaltyBox = require('../../src/evalpenaltybox').evalPenaltyBox; 2 | let out = require('./lib/out'); 3 | 4 | class DisableEvalPenaltyBoxCommand { 5 | constructor() { 6 | this.flags = 'disable-eval-penalty-box'; 7 | this.desc = 'Disable evaluation penalty box on the policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | run(options) { 33 | out.print({ 34 | promise: new EvalPenaltyBox(options).disablePenaltyBox(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new DisableEvalPenaltyBoxCommand(); 44 | -------------------------------------------------------------------------------- /bin/commands/ratepolicy.create.js: -------------------------------------------------------------------------------- 1 | let RatePolicy = require('../../src/ratepolicy').ratePolicy; 2 | let out = require('./lib/out'); 3 | 4 | class CreateRatePolicyCommand { 5 | constructor() { 6 | this.flags = 'create-rate-policy'; 7 | this.desc = 'Create a rate rule.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('<@path>', { 15 | paramsDesc: 'The input file path.' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }) 28 | .check((argv, context) => { 29 | if (!argv['@path'].startsWith('@')) { 30 | return context.cliMessage("ERROR: Invalid file name, should start with '@'"); 31 | } 32 | }); 33 | } 34 | 35 | run(options) { 36 | options.file = options['@path'].replace('@', ''); 37 | out.print({ 38 | promise: new RatePolicy(options).createRatePolicy(), 39 | args: options, 40 | success: (args, data) => { 41 | return data.id; 42 | } 43 | }); 44 | } 45 | } 46 | module.exports = new CreateRatePolicyCommand(); 47 | -------------------------------------------------------------------------------- /bin/commands/siem.modify.js: -------------------------------------------------------------------------------- 1 | let SiemSettings = require('../../src/siemsettings').siemSettings; 2 | let out = require('./lib/out'); 3 | 4 | class ModifySIEMCommand { 5 | constructor() { 6 | this.flags = 'modify-siem'; 7 | this.desc = 'Modify the SIEM settings.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('<@path>', { 15 | paramsDesc: 'The input file path.' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }) 28 | .check((argv, context) => { 29 | if (!argv['@path'].startsWith('@')) { 30 | return context.cliMessage("ERROR: Invalid file name, should start with '@'"); 31 | } 32 | }); 33 | } 34 | 35 | run(options) { 36 | options.file = options['@path'].replace('@', ''); 37 | out.print({ 38 | promise: new SiemSettings(options).updateSIEMSettings(), 39 | args: options, 40 | success: (args, data) => { 41 | return JSON.stringify(data); 42 | } 43 | }); 44 | } 45 | } 46 | module.exports = new ModifySIEMCommand(); 47 | -------------------------------------------------------------------------------- /bin/commands/attackgroups.js: -------------------------------------------------------------------------------- 1 | let AttackGroups = require('../../src/attackgroups').attackGroups; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'attackGroupActions'; 5 | 6 | class AttackGroupsCommand { 7 | constructor() { 8 | this.flags = 'attack-groups'; 9 | this.desc = 'Display attack groups and actions.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }) 27 | .string('--policy ', { 28 | desc: 29 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 30 | group: 'Optional:', 31 | required: false 32 | }); 33 | } 34 | run(options) { 35 | out.print({ 36 | promise: new AttackGroups(options).getAttackGroupActions(), 37 | args: options, 38 | objectType, 39 | success: (args, data) => { 40 | return JSON.stringify(data); 41 | } 42 | }); 43 | } 44 | } 45 | 46 | module.exports = new AttackGroupsCommand(); 47 | -------------------------------------------------------------------------------- /bin/commands/evalrules.js: -------------------------------------------------------------------------------- 1 | let EvalRules = require('../../src/evalrules').evalrules; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'evalRuleActions'; 5 | 6 | class EvalRuleActionsCommand { 7 | constructor() { 8 | this.flags = 'eval-rule-actions'; 9 | this.desc = 'Display evaluation rules and actions in a policy.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }) 27 | .string('--policy ', { 28 | desc: 29 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 30 | group: 'Optional:', 31 | required: false 32 | }); 33 | } 34 | run(options) { 35 | out.print({ 36 | promise: new EvalRules(options).getEvalRulesActions(), 37 | args: options, 38 | objectType, 39 | success: (args, data) => { 40 | return JSON.stringify(data); 41 | } 42 | }); 43 | } 44 | } 45 | 46 | module.exports = new EvalRuleActionsCommand(); 47 | -------------------------------------------------------------------------------- /bin/commands/penaltyboxconditions.js: -------------------------------------------------------------------------------- 1 | let PenaltyBoxConditions = require('../../src/penaltyboxconditions').penaltyBoxConditions; 2 | let out = require('./lib/out'); 3 | 4 | class PenaltyBoxConditionsCommand { 5 | constructor() { 6 | this.flags = 'penalty-box-conditions'; 7 | this.desc = 'Display penalty box conditions for a policy.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .number('--config ', { 15 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 16 | group: 'Optional:', 17 | required: false 18 | }) 19 | .string('--version ', { 20 | desc: 21 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 22 | group: 'Optional:', 23 | required: false 24 | }) 25 | .string('--policy ', { 26 | desc: 27 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 28 | group: 'Optional:', 29 | required: false 30 | }); 31 | } 32 | run(options) { 33 | out.print({ 34 | promise: new PenaltyBoxConditions(options).getPenaltyBoxConditions(), 35 | args: options, 36 | success: (args, data) => { 37 | return JSON.stringify(data); 38 | } 39 | }); 40 | } 41 | } 42 | 43 | module.exports = new PenaltyBoxConditionsCommand(); 44 | -------------------------------------------------------------------------------- /mock/activations/status/f81c92c5-b150-4c41-9b53-9cef7969150a.json: -------------------------------------------------------------------------------- 1 | { 2 | "responseToChoose": 0, 3 | "responses": [ 4 | { 5 | "httpStatus": 200, 6 | "response": { 7 | "statusCode": 200, 8 | "body": { 9 | "statusCode": 200, 10 | "statusId": "f81c92c5-b150-4c41-9b53-9cef7969150a", 11 | "createDate": "2018-06-19T11:27:55Z" 12 | } 13 | } 14 | }, 15 | { 16 | "httpStatus": 303, 17 | "response": { 18 | "headers": { 19 | "location": "configs/1234/versions/1/activations/1" 20 | }, 21 | "statusCode": 303, 22 | "body": { 23 | "statusCode": 303, 24 | "statusId": "f81c92c5-b150-4c41-9b53-9cef7969150a", 25 | "createDate": "2018-06-19T11:27:55Z", 26 | "links": { 27 | "check-status": { 28 | "href": "activations/status/f81c92c5-b150-4c41-9b53-9cef7969150a" 29 | } 30 | } 31 | } 32 | } 33 | }, 34 | { 35 | "httpStatus": 403, 36 | "response": { 37 | "statusCode": 403, 38 | "status": 403, 39 | "title": "Unauthorized", 40 | "detail": "You are not authorized to do this!" 41 | } 42 | } 43 | ] 44 | } -------------------------------------------------------------------------------- /bin/commands/ratepolicy.actions.js: -------------------------------------------------------------------------------- 1 | let RatePolicy = require('../../src/ratepolicy').ratePolicy; 2 | let out = require('./lib/out'); 3 | 4 | const objectType = 'ratePolicyActions'; 5 | 6 | class RateActionCommand { 7 | constructor() { 8 | this.flags = 'rate-policies-actions'; 9 | this.desc = 'Display all enabled rate policy actions.'; 10 | this.setup = this.setup.bind(this); 11 | this.run = this.run.bind(this); 12 | } 13 | 14 | setup(sywac) { 15 | sywac 16 | .number('--config ', { 17 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 18 | group: 'Optional:', 19 | required: false 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:', 25 | required: false 26 | }) 27 | .string('--policy ', { 28 | desc: 29 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 30 | group: 'Optional:', 31 | required: false 32 | }); 33 | } 34 | run(options) { 35 | out.print({ 36 | promise: new RatePolicy(options).getAllRatePolicyActions(), 37 | args: options, 38 | objectType, 39 | success: (args, data) => { 40 | return JSON.stringify(data); 41 | } 42 | }); 43 | } 44 | } 45 | 46 | module.exports = new RateActionCommand(); 47 | -------------------------------------------------------------------------------- /bin/commands/customdeny.create.js: -------------------------------------------------------------------------------- 1 | let CustomDeny = require('../../src/customdeny').customdeny; 2 | let out = require('./lib/out'); 3 | 4 | class CreateCustomDenyCommand { 5 | constructor() { 6 | this.flags = 'create-custom-deny'; 7 | this.desc = 'Create a custom deny action.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('<@path>', { 15 | paramsDesc: 'The input file path.' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:', 20 | required: false 21 | }) 22 | .string('--version ', { 23 | desc: 24 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 25 | group: 'Optional:', 26 | required: false 27 | }) 28 | .check((argv, context) => { 29 | if (!argv['@path'].startsWith('@')) { 30 | return context.cliMessage("ERROR: Invalid file name, should start with '@'"); 31 | } 32 | }); 33 | } 34 | 35 | run(options) { 36 | options.file = options['@path'].replace('@', ''); 37 | 38 | out.print({ 39 | promise: new CustomDeny(options).addCustomdeny(), 40 | args: options, 41 | success: (args, data) => { 42 | return JSON.stringify(data); 43 | } 44 | }); 45 | } 46 | } 47 | 48 | module.exports = new CreateCustomDenyCommand(); 49 | -------------------------------------------------------------------------------- /bin/commands/recategorizedakamaidefinedbot.js: -------------------------------------------------------------------------------- 1 | let RecategorizedAkamaiDefinedBot = require('../../src/recategorizedakamaidefinedbot') 2 | .recategorizedakamaidefinedbot; 3 | let out = require('./lib/out'); 4 | 5 | class RecategorizedAkamaiDefinedBotCommand { 6 | constructor() { 7 | this.flags = 'recategorized-akamai-defined-bot'; 8 | this.desc = 'Display contents of recategorized akamai defined bot.'; 9 | this.setup = this.setup.bind(this); 10 | this.run = this.run.bind(this); 11 | } 12 | 13 | setup(sywac) { 14 | sywac 15 | .positional('', { 16 | paramsDesc: 'Akamai Defined Bot ID' 17 | }) 18 | .number('--config ', { 19 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 20 | group: 'Optional:', 21 | required: false 22 | }) 23 | .string('--version ', { 24 | desc: 25 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 26 | group: 'Optional:', 27 | required: false 28 | }); 29 | } 30 | 31 | run(options) { 32 | options.akamai_defined_bot_id = options['akamai-defined-bot-id']; 33 | 34 | out.print({ 35 | promise: new RecategorizedAkamaiDefinedBot(options).getRecategorizedAkamaiDefinedBot(), 36 | args: options, 37 | success: (args, data) => { 38 | return JSON.stringify(data); 39 | } 40 | }); 41 | } 42 | } 43 | 44 | module.exports = new RecategorizedAkamaiDefinedBotCommand(); 45 | -------------------------------------------------------------------------------- /src/policyprotection.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let URIs = require('./constants').URIS; 4 | //needed to pass files to PUT/POST 5 | let fs = require('fs'); 6 | //Ensures user can add paths like '~/foo' 7 | let untildify = require('untildify'); 8 | let Config = require('./configprovider').configProvider; 9 | let Version = require('./versionsprovider').versionProvider; 10 | let PolicyProvider = require('./policy').policy; 11 | class PolicyProtections { 12 | constructor(options) { 13 | this._config = new Config(options); 14 | this._options = options; 15 | this._version = new Version(options); 16 | this._policyProvider = new PolicyProvider(options); 17 | } 18 | 19 | getProtections() { 20 | return this._policyProvider.policyId().then(policyId => { 21 | return this._version.readResource(URIs.POLICY_PROTECTIONS, [policyId]); 22 | }); 23 | } 24 | 25 | setProtections() { 26 | if (fs.existsSync(this._options['file'])) { 27 | return this._policyProvider.policyId().then(policyId => { 28 | let payload = fs.readFileSync(untildify(this._options['file']), 'utf8'); 29 | let data; 30 | try { 31 | data = JSON.parse(payload); 32 | } catch (err) { 33 | throw 'The input JSON is not valid'; 34 | } 35 | return this._version.updateResource(URIs.POLICY_PROTECTIONS, [policyId], data); 36 | }); 37 | } else { 38 | throw `The file does not exists: ${this._options['file']}`; 39 | } 40 | } 41 | } 42 | 43 | module.exports = { 44 | policyProtection: PolicyProtections 45 | }; 46 | -------------------------------------------------------------------------------- /bin/commands/attackgroup.disable.js: -------------------------------------------------------------------------------- 1 | let AttackGroups = require('../../src/attackgroups').attackGroups; 2 | let out = require('./lib/out'); 3 | 4 | class DisableAttackGroupCommand { 5 | constructor() { 6 | this.flags = 'disable-attack-group'; 7 | this.desc = 'Disable attack group.'; 8 | this.setup = this.setup.bind(this); 9 | this.run = this.run.bind(this); 10 | } 11 | 12 | setup(sywac) { 13 | sywac 14 | .positional('', { 15 | paramsDesc: 'The attack group name.' 16 | }) 17 | .number('--config ', { 18 | desc: 'Configuration ID. Mandatory if you have more than one configuration.', 19 | group: 'Optional:' 20 | }) 21 | .string('--version ', { 22 | desc: 23 | "Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.", 24 | group: 'Optional:' 25 | }) 26 | .string('--policy ', { 27 | desc: 28 | 'Policy ID. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.', 29 | group: 'Optional:' 30 | }); 31 | } 32 | 33 | run(options) { 34 | options.group = options['attack-group-name']; 35 | out.print({ 36 | promise: new AttackGroups(options).disableAttackGroup(), 37 | args: options, 38 | success: (args, data) => { 39 | return JSON.stringify(data); 40 | } 41 | }); 42 | } 43 | } 44 | 45 | module.exports = new DisableAttackGroupCommand(); 46 | --------------------------------------------------------------------------------