示例#1
0
        public async Task ExecuteAsync(string[] args)
        {
            _logger.WriteStart(_dateTimeProvider.Snapshot);

            if (args.Length != 1)
            {
                throw new ArgumentException("The SigTestFileCreator requires one file as a command-line argument.");
            }

            if (Environment.UserInteractive && !WindowsIdentityQueries.CurrentUserIsAdministrator())
            {
                _logger.WriteNoElevatedPrivs();
            }

            var fullPath      = Path.GetFullPath(args[0].Trim());
            var fileDirectory = Path.GetDirectoryName(fullPath);
            var fileName      = Path.GetFileNameWithoutExtension(fullPath);

            var fileContents = File.ReadAllBytes(fullPath);

            var signedFileContents = await BuildEksOutputAsync(fileContents);

            _logger.WriteSavingResultfile();
            using (var outputFile = File.Create($"{fileDirectory}\\{fileName}-signed.zip", 1024, FileOptions.None))
            {
                outputFile.Write(signedFileContents);
            }

            _logger.WriteFinished(fileDirectory);
        }
示例#2
0
        public async Task ExecuteAsync(string[] args)
        {
            _Logger.WriteStart(_DateTimeProvider.Snapshot);

            if (args.Length > 1)
            {
                throw new ArgumentException("The tester was started with more than one argument: ", String.Join(";", args));
            }
            else if (args.Length == 1)
            {
                var CleanedInput             = args[0].Trim();
                var FilePathWithoutExtension = CleanedInput.Substring(0, CleanedInput.LastIndexOf('.'));

                _fileInputLocation     = CleanedInput;
                _eksFileOutputLocation = FilePathWithoutExtension + "-eks" + ".Zip";
            }

            if (Environment.UserInteractive && !WindowsIdentityQueries.CurrentUserIsAdministrator())
            {
                _Logger.WriteNoElevatedPrivs();
            }

            LoadFile(_fileInputLocation);
            var eksZipOutput = await BuildEksOutputAsync();

            _Logger.WriteSavingResultfile();
            ExportOutput(_eksFileOutputLocation, eksZipOutput);

            _Logger.WriteFinished(_eksFileOutputLocation);
        }