Skip to content

Commit

Permalink
Merge pull request #25 from akamai/release/1.9.0
Browse files Browse the repository at this point in the history
Release/1.9.0 => Master
  • Loading branch information
atuljain16 authored Nov 18, 2020
2 parents 13a7b69 + 8a32140 commit 7356df1
Show file tree
Hide file tree
Showing 132 changed files with 1,828 additions and 992 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ Commands:
add-hostname Add hostnames to selected list.
selectable-hostnames List all selectable hostnames.
selected-hostnames List all currently chosen hostnames.
create-match-target Creates a match target.
modify-match-target Updates a match target.
create-match-target Creates a website match target.
delete-match-target Deletes a match target.
modify-match-target Updates a website match target.
create-api-match-target (Beta) Creates an API match target.
modify-api-match-target (Beta) Updates an API match target.
match-target-order Change the match target sequence.
match-targets List all match targets.
match-target (Beta) Read a match target.
policies List all security policies.
clone-policy Clone security policy.
version Read a config version.
Expand Down Expand Up @@ -140,6 +144,11 @@ Commands:
protect-eval-hostnames (Beta) Move evaluation hostnames to protection.
eval-hostnames (Beta) List all hosts under evaluation.
modify-eval-hostnames (Beta) Modify hostnames under evaluation.
bypass-network-lists (Beta) List all bypass network lists.
modify-bypass-network-lists (Beta) Update bypass network lists.
hostname-coverage (Beta) Display the Hostname Coverage.
version-notes (Beta) Display the version notes.
modify-version-notes (Beta) Update the version notes.
Command options:
--json Print the raw json response. All commands respect this option. [boolean]
Expand Down
2 changes: 1 addition & 1 deletion bin/akamai-appsec
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require("sywac")
})
.epilogue("Copyright (C) Akamai Technologies, Inc\nVisit http://github.com/akamai/cli-appsec for detailed documentation\n")
.outputSettings({
maxWidth: 125
maxWidth: 150
})
.parse()
.then(result => {
Expand Down
35 changes: 19 additions & 16 deletions bin/commands/activate.version.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,38 @@ class ActivateVersionCommand {

setup(sywac) {
sywac
.usage('Usage: akamai-appsec activate --network <network> --notify <emails> [options]')
.enumeration('--network <network>', {
desc: 'The network in which the configuration must be activated.',
choices: ['PRODUCTION', 'STAGING'],
group: 'Required:',
required: true
})
.stringArray('--notify <emails>', {
desc: 'The comma separated email ids to get notification.',
group: 'Required:',
required: true
})
.number('--config <id>', {
desc: 'Configuration ID.',
group: 'Options:',
desc: 'Configuration ID. Mandatory if you have more than one configuration.',
group: 'Optional:',
required: false
})
.string('--version <id>', {
desc: 'Version Number.',
group: 'Options:',
desc:
"Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.",
group: 'Optional:',
required: false
})
.enumeration('--network <network>', {
desc: 'The network in which the configuration must be activated.',
choices: ['PRODUCTION', 'STAGING'],
required: true
})
.string('--note <note>', {
desc: 'The activation notes.',
group: 'Options:',
group: 'Optional:',
required: false
})
.stringArray('--notify <emails>', {
desc: 'The comma separated email ids to get notification.',
group: 'Options:',
required: true
})
.stringArray('--acknowledge-invalid-hosts <invalid hostnames>', {
desc:
'In some cases, you may wish to activate a security configuration which targets hosts to which protection cannot be applied (for example, hosts not managed as Akamai properties). This will block activation with a warning, which will include the names of the invalid hosts. If you want to activate anyway, use this parameter to provide a comma-separated list of invalid host names to acknowledge the warning.',
group: 'Options:',
group: 'Optional:',
required: false
});
}
Expand Down
7 changes: 4 additions & 3 deletions bin/commands/activation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ class ActivationStatusCommand {

setup(sywac) {
sywac
.usage('Usage: akamai-appsec activation --activation-id <id> [options]')
.number('--activation-id <id>', {
desc: 'Activation request id.',
group: 'Options:',
desc: 'Activation request ID.',
group: 'Required:',
required: true
})
.boolean('--verbose', {
desc: 'Provides more details about the activation status.',
group: 'Options:',
group: 'Optional:',
required: false
});
}
Expand Down
16 changes: 8 additions & 8 deletions bin/commands/apiconstraint.disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ class DisableApiConstraintCommand {
setup(sywac) {
sywac
.number('--config <id>', {
desc: 'Configuration id. Mandatory if you have more than one configuration.',
group: 'Options:',
desc: 'Configuration ID. Mandatory if you have more than one configuration.',
group: 'Optional:',
required: false
})
.string('--version <id>', {
desc:
"The version number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.",
group: 'Options:',
"Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.",
group: 'Optional:',
required: false
})
.string('--policy <id>', {
desc:
'The policy id to use. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.',
group: 'Options:',
'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.',
group: 'Optional:',
required: false
})
.string('--api <id>', {
desc:
'The api id to use. If not provided, the request constraints action is disabled for all the associated match target api ids.',
group: 'Options:',
'API ID. If not provided, the request constraints action is disabled for all the associated match target API IDs.',
group: 'Optional:',
required: false
});
}
Expand Down
29 changes: 16 additions & 13 deletions bin/commands/apiconstraint.enable.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,36 @@ class EnableApiConstraintCommand {

setup(sywac) {
sywac
.usage('Usage: akamai-appsec enable-api-request-constraints --action <action> [options]')
.string('--action <action>', {
desc:
"Action to assign. Use - \n\t\t • 'alert': To record the trigger of the event; \n\t\t • 'deny': To block the request; \n\t\t • 'deny_custom_{custom_deny_id}': To trigger a custom deny; \n\t\t • 'none': To disassociate with the policy;",
group: 'Required:',
hints: '[required] [alert, deny, deny_custom_{custom_deny_id}, none]',
required: true
})
.number('--config <id>', {
desc: 'Configuration id. Mandatory if you have more than one configuration.',
group: 'Options:',
desc: 'Configuration ID. Mandatory if you have more than one configuration.',
group: 'Optional:',
required: false
})
.string('--version <id>', {
desc:
"The version number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.",
group: 'Options:',
"Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.",
group: 'Optional:',
required: false
})
.string('--policy <id>', {
desc:
'The policy id to use. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.',
group: 'Options:',
'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.',
group: 'Optional:',
required: false
})
.string('--api <id>', {
desc:
'The api id to use. If not provided, the request constraints action is set for all the associated match target api ids.',
group: 'Options:',
'API ID. If not provided, the request constraints action is set for all the associated match target API IDs.',
group: 'Optional:',
required: false
})
.string('--action <id>', {
desc: 'Action to assign. ',
group: 'Options:',
required: true
});
}

Expand Down
12 changes: 6 additions & 6 deletions bin/commands/apiconstraint.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ class ApiConstraintCommand {
setup(sywac) {
sywac
.number('--config <id>', {
desc: 'Configuration id. Mandatory if you have more than one configuration.',
group: 'Options:',
desc: 'Configuration ID. Mandatory if you have more than one configuration.',
group: 'Optional:',
required: false
})
.string('--version <id>', {
desc:
"The version number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.",
group: 'Options:',
"Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.",
group: 'Optional:',
required: false
})
.string('--policy <id>', {
desc:
'The policy id to use. If not provided, we try to use the policy available on file. If you have more than one policy, this option must be provided.',
group: 'Options:',
'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.',
group: 'Optional:',
required: false
});
}
Expand Down
6 changes: 3 additions & 3 deletions bin/commands/apiendpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ class ListAPIEndpointsCommand {
sywac
.number('--config <id>', {
desc: 'Configuration ID. Mandatory if you have more than one configuration.',
group: 'Options:',
group: 'Optional:',
required: false
})
.string('--version <id>', {
desc:
"Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.",
group: 'Options:',
group: 'Optional:',
required: false
})
.string('--policy <id>', {
desc: 'Policy ID. If not provided, we try to use the policy available on file.',
group: 'Options:',
group: 'Optional:',
required: false
});
}
Expand Down
50 changes: 50 additions & 0 deletions bin/commands/apimatchtarget.create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
let out = require('./lib/out');
let MatchTarget = require('../../src/matchtarget').matchTarget;

class CreateApiMatchTargetCommand {
constructor() {
this.flags = 'create-api-match-target';
this.desc = '(Beta) Creates an API match target.';
this.setup = this.setup.bind(this);
this.run = this.run.bind(this);
}

setup(sywac) {
sywac
.usage('Usage: akamai-appsec create-api-match-target --apis <123, 456, 789> [options]')
.numberArray('--apis <apiId1, apiId2, apiId3>', {
desc: 'APIs to add.',
group: 'Required:',
required: true
})
.number('--config <id>', {
desc: 'Configuration ID. Mandatory if you have more than one configuration.',
group: 'Optional:',
required: false
})
.string('--version <id>', {
desc:
"Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.",
group: 'Optional:',
required: false
})
.string('--policy <id>', {
desc:
'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.',
group: 'Optional:',
required: false
});
}

run(options) {
out.print({
promise: new MatchTarget(options).createApiMatchTarget(),
args: options,
success: (args, data) => {
return data.targetId;
}
});
}
}

module.exports = new CreateApiMatchTargetCommand();
64 changes: 64 additions & 0 deletions bin/commands/apimatchtarget.modify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
let out = require('./lib/out');
let MatchTarget = require('../../src/matchtarget').matchTarget;
let logger = require('../../src/constants').logger('modify-api-match-target');

const SUB_CPMMANDS = ['add-api'];
class ModifyAPIMatchTargetCommand {
constructor() {
this.flags = 'modify-api-match-target';
this.desc = '(Beta) Updates an API match target.';
this.setup = this.setup.bind(this);
this.run = this.run.bind(this);
}

setup(sywac) {
sywac
.positional('<match-target>', {
paramsDesc: 'The match target ID.'
})
.positional('<subcommand>', {
paramsDesc: 'The subcommand. [' + SUB_CPMMANDS.join(',') + ']'
})
.positional('<api>', {
paramsDesc: 'The api to add to the match target.'
})
.number('--config <id>', {
desc: 'Configuration ID. Mandatory if you have more than one configuration.',
group: 'Optional:',
required: false
})
.string('--version <id>', {
desc:
"Version Number. It can also take the values 'PROD' or 'PRODUCTION' or 'STAGING'. If not provided, latest version is assumed.",
group: 'Optional:',
required: false
})
.check((argv, context) => {
if (!SUB_CPMMANDS.includes(argv.subcommand)) {
return context.cliMessage('Could not recognize the command: ' + argv.subcommand);
}
});
}

run(options) {
logger.debug(JSON.stringify(options));
out.print({
promise: this._getOperation(options),
args: options,
success: (args, data) => {
return data.targetId;
}
});
}

_getOperation(options) {
switch (options.subcommand) {
case 'add-api':
return new MatchTarget(options).addApi();
default:
return null;
}
}
}

module.exports = new ModifyAPIMatchTargetCommand();
Loading

0 comments on commit 7356df1

Please sign in to comment.