Skip to content

Commit

Permalink
Fixinator v5
Browse files Browse the repository at this point in the history
Add support for goals to fixinator client
  • Loading branch information
pfreitag committed Oct 31, 2024
1 parent 09d555f commit 54e85a2
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 30 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ Added in Fixinator version 4.

The path to a `.fixinator.json` configuration file to use. See below for details on the file contents. The command line argument overrides the default search path (looking in the base directory).

### goals

Default: `security` - a comma separated list of goals for the scan. Possible values are `security` and `compatibility`

When the `compatibility` goal is passed it will return compatibility issues found in the code for the `engines` specified. Typically when you use the `compatibility` mode you will specify the `engines` argument as well. Example

fixinator path=c:\mycode\ goals=security,compatibility engines=adobe@2023

Added in Fixinator Version 5.

## Environment Variables

Expand Down
4 changes: 2 additions & 2 deletions box.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name":"fixinator",
"version":"4.1.0",
"version":"5.0.0",
"author":"Foundeo Inc.",
"location":"foundeo/fixinator#v4.1.0",
"location":"foundeo/fixinator#v5.0.0",
"homepage":"https://fixinator.app/",
"documentation":"https://github.com/foundeo/fixinator/wiki",
"repository":{
Expand Down
66 changes: 39 additions & 27 deletions commands/fixinator.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ component extends="commandbox.system.BaseCommand" excludeFromHelp=false {
* @engines.hint A list of engines your code runs on, eg: lucee@5,adobe@2023 default any
* @includeScanners.hint A comma seperated list of scanner ids to scan, all others ignored
* @configFile.hint A path to a .fixinator.json file to use
* @goals.hint A list of goals for scanning [compatibility,security], default: security
**/
function run(
string path=".",
Expand All @@ -58,7 +59,8 @@ component extends="commandbox.system.BaseCommand" excludeFromHelp=false {
boolean gitChanged=false,
string engines="",
string includeScanners="",
string configFile=""
string configFile="",
string goals="security"
) {
var fileInfo = "";
var severityLevel = 1;
Expand Down Expand Up @@ -321,6 +323,9 @@ component extends="commandbox.system.BaseCommand" excludeFromHelp=false {
if (len(arguments.includeScanners)) {
config.includeScanners = listToArray(replace(arguments.includeScanners, " ", "", "ALL"));
}
if (len(arguments.goals)) {
config["goals"] = listToArray(replace(arguments.goals, " ", "", "ALL"));
}

if (len(arguments.configFile)) {
arguments.configFile = fileSystemUtil.resolvePath( arguments.configFile );
Expand Down Expand Up @@ -606,23 +611,7 @@ component extends="commandbox.system.BaseCommand" excludeFromHelp=false {
}
}

if (arguments.listScanners && local.results.keyExists("categories")) {
print.line();
print.line("Results by Scanner (confidence=#local.results.config.minConfidence#, severity=#local.results.config.minSeverity#):");
for (local.cat in local.results.categories) {
local.issues = 0;
for (local.i in local.results.results) {
if (local.i.id == local.cat) {
local.issues++;
}
}
if (local.issues == 0) {
print.greenLine("" & local.results.categories[cat].name & " [" & cat & "]" );
} else {
print.redLine(" ! " & local.results.categories[cat].name & " [" & cat & "] (" & local.issues & ")" );
}
}
}


/*
for (local.i in local.results.results) {
Expand Down Expand Up @@ -663,20 +652,38 @@ component extends="commandbox.system.BaseCommand" excludeFromHelp=false {
}


if (arguments.debug) {
local.debugLogFile = expandPath("{lucee-web}/logs/fixinator-client-debug.log");
print.line();
if (fileExists(local.debugLogFile)) {
print.boldGreenLine("Debug information logged to: #local.debugLogFile#");




}

if (arguments.listScanners && local.results.keyExists("categories")) {
print.line();
print.line("Results by Scanner (confidence=#local.results.config.minConfidence#, severity=#local.results.config.minSeverity#):");
for (local.cat in local.results.categories) {
local.issues = 0;
for (local.i in local.results.results) {
if (local.i.id == local.cat) {
local.issues++;
}
}
if (local.issues == 0) {
print.greenLine("" & local.results.categories[cat].name & " [" & cat & "]" );
} else {
print.boldRedLine("Expected debug information to be logged to: #local.debugLogFile# but the file does not exist.");
print.redLine(" ! " & local.results.categories[cat].name & " [" & cat & "] (" & local.issues & ")" );
}
}
}

if (arguments.failOnIssues) {
setExitCode( 1 );
if (arguments.debug) {
local.debugLogFile = expandPath("{lucee-web}/logs/fixinator-client-debug.log");
print.line();
if (fileExists(local.debugLogFile)) {
print.boldGreenLine("Debug information logged to: #local.debugLogFile#");
} else {
print.boldRedLine("Expected debug information to be logged to: #local.debugLogFile# but the file does not exist.");
}

}

if (fixinatorClient.hasClientUpdate()) {
Expand All @@ -686,6 +693,11 @@ component extends="commandbox.system.BaseCommand" excludeFromHelp=false {
}


if (arrayLen(local.results.results) > 0 ) {
if (arguments.failOnIssues) {
setExitCode( 1 );
}
}

}

Expand Down
2 changes: 1 addition & 1 deletion models/fixinator/FixinatorClient.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ component singleton="true" {
} else if (httpResult.statusCode contains "429") {
//TOO MANY REQUESTS
if (arguments.isRetry == 1) {
throw(message="Fixinator API Returned 429 Status Code (Too Many Requests). This is usually due to an exceded monthly quote limit. You can either purchase a bigger plan or request a one time limit increase.", type="FixinatorClient");
throw(message="Fixinator API Returned 429 Status Code (Too Many Requests). This is usually due to an exceeded monthly quota limit. You can either purchase a bigger plan or request a one time limit increase.", type="FixinatorClient");
} else {
//retry it once
sleep(1500);
Expand Down

0 comments on commit 54e85a2

Please sign in to comment.