[ACS-5987] improved security for shell scripts (#8889)

* improved security for node process functions

* improved security for node process functions

* remove unused file from demo shell

* restore regex

* fix regex

* update escaping

* lint fixes

* fix typo

* fix export

* fix exports

* fix lint

* fix lint
This commit is contained in:
Denys Vuika
2023-09-27 10:52:33 +01:00
committed by GitHub
parent 6d8c513180
commit 8f684a9f6a
20 changed files with 233 additions and 311 deletions

View File

@@ -17,6 +17,7 @@
* limitations under the License.
*/
import { argv, exit } from 'node:process';
import { exec } from './exec';
import { logger } from './logger';
import program from 'commander';
@@ -38,25 +39,20 @@ function zipArtifact(output: string) {
logger.info(response);
}
export default function() {
main();
}
function main() {
export default function main() {
program
.version('0.1.0')
.requiredOption('-a, --artifact [type]', ' path to the s3 artifact (tar.bz2) to download and extract')
.requiredOption('-o, --output [type]', 'directory to extract the archive to')
.parse(process.argv);
.parse(argv);
if (process.argv.includes('-h') || process.argv.includes('--help')) {
if (argv.includes('-h') || argv.includes('--help')) {
program.outputHelp();
return;
}
if (!program.artifact || program.artifact === '' || !program.output || program.output === '') {
process.exit(1);
exit(1);
} else if (program.artifact !== '' || program.output !== '') {
zipArtifact(program.artifact);
awsCp(program.output);