diff --git a/ASVS_v4.0_Checklist.ods b/ASVS_v4.0_Checklist.ods index 0ba1862..2e12f5a 100644 Binary files a/ASVS_v4.0_Checklist.ods and b/ASVS_v4.0_Checklist.ods differ diff --git a/ASVS_v4.0_Checklist.xlsx b/ASVS_v4.0_Checklist.xlsx index 1cc224f..a0e14ac 100644 Binary files a/ASVS_v4.0_Checklist.xlsx and b/ASVS_v4.0_Checklist.xlsx differ diff --git a/README.md b/README.md index 2cfdd48..f90f6f4 100644 --- a/README.md +++ b/README.md @@ -21,5 +21,5 @@ Script Usage You most likely won't need this. But if you need to re-parse the CSV into individual files for easier usage, run this: ```shell -$ ./parse_csv resources/OWASP_Application_Security_Verification_Standard_4.0-en.csv +$ ./csvparse resources/OWASP_Application_Security_Verification_Standard_4.0-en.csv ``` diff --git a/parse_csv b/csvparse similarity index 57% rename from parse_csv rename to csvparse index ae3ab06..a431c1e 100755 --- a/parse_csv +++ b/csvparse @@ -8,18 +8,18 @@ namespace { error('No csv file supplied'); } - $fp = @fopen($argv[1], 'r'); + $fp = owasp_asvs\get_input_file_handle($argv[1]); - if ($fp === false) { - error('Unable to read csv file'); - } + while (!feof($fp)) { + $elements = fgetcsv($fp); - fgets($fp); // skip header line + if ($elements === false || count($elements) < 8) { + error('Invalid csv file'); + } - while (!feof($fp)) { - [, $name, $item, $desc, $l1, $l2, , $cwe] = fgetcsv($fp); + [ , $name, $item, $desc, $l1, $l2, , $cwe] = $elements; - owasp_asvs\write($name, [$item, owasp_asvs\level($l1, $l2), $desc, $cwe]); + owasp_asvs\write($name, [$item, $cwe, owasp_asvs\level($l1, $l2), $desc]); } } @@ -51,20 +51,34 @@ namespace owasp_asvs { error('Invalid category name'); } - $handles[$name] = @fopen(__DIR__ . "/parsed/{$name}.csv", 'w+'); + $handle = @fopen(__DIR__ . "/parsed/{$name}.csv", 'w+'); - if ($handles[$name] === false) { + if ($handle === false) { error('Unable to open output file'); } - register_shutdown_function(function () use ($handles, $name) { - fclose($handles[$name]); + $handles[$name] = $handle; + + register_shutdown_function(function () use (&$handle) { + fclose($handle); }); } return $handles[$name]; } + function get_input_file_handle(string $path) + { + $fp = @fopen($path, 'r'); + + if ($fp === false) { + error('Unable to read csv file'); + } + + fgets($fp); + return $fp; // skip header line + } + function error(string $message): void { echo $message, PHP_EOL; diff --git a/macros/onEdit.js b/macros/onEdit.js deleted file mode 100644 index a7a5393..0000000 --- a/macros/onEdit.js +++ /dev/null @@ -1,12 +0,0 @@ -function onEdit(event) { - var isApplicableRow = 5; - var tableRange = "A2:H200"; - - var sheet = SpreadsheetApp.getActiveSpreadsheet(); - var editedCell = sheet.getActiveCell(); - - if (editedCell.getValue() === 'Not Applicable') { - var range = sheet.getRange(tableRange); - range.sort({ column : isApplicableRow, ascending: false }); - } -} diff --git a/resources/screenshot.png b/resources/screenshot.png index b69fab7..327d1bc 100644 Binary files a/resources/screenshot.png and b/resources/screenshot.png differ diff --git a/resources/screenshot2.png b/resources/screenshot2.png index e994614..c7064fd 100644 Binary files a/resources/screenshot2.png and b/resources/screenshot2.png differ