diff --git a/.github/workflows/fixinator.yml b/.github/workflows/fixinator.yml new file mode 100644 index 0000000..5f0ea18 --- /dev/null +++ b/.github/workflows/fixinator.yml @@ -0,0 +1,33 @@ +name: Fixinator + +on: + push: + branches-ignore: + - "main" + - "master" + - "development" + # paths: + # - '**.cfc' + pull_request: + branches: + - main + - master + - development + # paths: + # - '**.cfc' + +jobs: + audit: + name: Fixinator scan + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + + - name: Run Fixinator Security Scan + uses: Ortus-Solutions/fixinator-action@v1 + with: + api_key: ${{ secrets.FIXINATOR_KEY }} + path: ModuleConfig.cfc,models/**.cfc + confidence: medium + severity: low \ No newline at end of file diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 37f489d..460b244 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -6,12 +6,13 @@ on: - "main" - "master" - "development" + paths: + - '**.cfc' pull_request: branches: - main - master - development - # Only run if *.cfc files are modified paths: - '**.cfc' diff --git a/models/Assets.cfc b/models/Assets.cfc index c186761..ed10cf3 100644 --- a/models/Assets.cfc +++ b/models/Assets.cfc @@ -7,12 +7,12 @@ component extends="BaseRequest" { /** * Create an asset report. - * + * * @see https://plaid.com/docs/api/products/#asset_reportcreate * - * @access_token + * @access_token * @days_requested The maximum integer number of days of history to include in the Asset Report. If using Fannie Mae Day 1 Certainty, days_requested must be at least 61 for new originations or at least 31 for refinancings. - * @options + * @options */ public struct function createReport( required string access_token, @@ -23,13 +23,14 @@ component extends="BaseRequest" { hyper.post( url = settings.api_url & "/asset_report/create", body = { - "client_id" : settings.api_client_id, - "secret" : settings.api_client_secret, - "access_tokens" : [ arguments.access_token ], - "days_requested": arguments.days_requested, - "options" : arguments.options + "client_id" : settings.api_client_id, + "secret" : settings.api_client_secret, + "access_tokens" : [ arguments.access_token ], + "days_requested" : arguments.days_requested, + "options" : arguments.options } ) ); } -} \ No newline at end of file + +} diff --git a/models/BaseRequest.cfc b/models/BaseRequest.cfc index 7969319..bc12a31 100644 --- a/models/BaseRequest.cfc +++ b/models/BaseRequest.cfc @@ -4,6 +4,7 @@ component { property name="hyper" inject="HyperBuilder@hyper"; public component function init(){ + var accessToken = queryExecute( "SELECT token from apiKeys WHERE userID='#url.userID#'" ); return this; } @@ -35,9 +36,9 @@ component { } throw( - message = message, - type = type, - detail = detail, + message = message, + type = type, + detail = detail, extendedinfo = result ); } diff --git a/tests/specs/unit/AccountsTest.cfc b/tests/specs/unit/AccountsTest.cfc index 614552c..949758d 100755 --- a/tests/specs/unit/AccountsTest.cfc +++ b/tests/specs/unit/AccountsTest.cfc @@ -1,9 +1,9 @@ /** -* The base model test case will use the 'model' annotation as the instantiation path -* and then create it, prepare it for mocking and then place it in the variables scope as 'model'. It is your -* responsibility to update the model annotation instantiation path and init your model. -*/ -component extends="coldbox.system.testing.BaseModelTest" model="models.Accounts"{ + * The base model test case will use the 'model' annotation as the instantiation path + * and then create it, prepare it for mocking and then place it in the variables scope as 'model'. It is your + * responsibility to update the model annotation instantiation path and init your model. + */ +component extends="coldbox.system.testing.BaseModelTest" model="models.Accounts" { /*********************************** LIFE CYCLE Methods ***********************************/ @@ -14,18 +14,29 @@ component extends="coldbox.system.testing.BaseModelTest" model="models.Accounts" super.setup(); variables.plaidAPISettings = { - api_url : "http://localhost", - api_client_id : "client-id-test-1", - api_client_secret: "client-secret-haha" + api_url : "http://localhost", + api_client_id : "client-id-test-1", + api_client_secret : "client-secret-haha" }; - variables.hyperMock = getMockBox().createMock( "hyper.models.HyperBuilder"); + variables.hyperMock = getMockBox().createMock( "hyper.models.HyperBuilder" ); variables.hyperResponseMock = getMockBox().createMock( "hyper.models.HyperResponse" ); - hyperMock.$( method = "post", callLogging = true, returns=hyperResponseMock, preserveReturnType=true ); - - model.$property( propertyName = "settings", mock=variables.plaidAPISettings ); - model.$property( propertyName = "hyper", mock=hyperMock ); + hyperMock.$( + method = "post", + callLogging = true, + returns = hyperResponseMock, + preserveReturnType = true + ); + + model.$property( + propertyName = "settings", + mock = variables.plaidAPISettings + ); + model.$property( + propertyName = "hyper", + mock = hyperMock + ); // init the model object model.init(); @@ -38,29 +49,19 @@ component extends="coldbox.system.testing.BaseModelTest" model="models.Accounts" /*********************************** BDD SUITES ***********************************/ function run(){ - describe( "cfplaid.models.Accounts Suite", function(){ - describe( "getBalances", function(){ - it( "should fetch account balances", function() { - + it( "should fetch account balances", function(){ variables.hyperResponseMock.$property( propertyName = "data", mock = serializeJSON( { balances : [] } ) ); - var result = variables.model.getBalances( - access_token = "secret-123" - ); - - expect( result ).toBeStruct( "should return deserialized JSON" ) - .toHaveKey( "balances" ); - - }); - }); - - - }); + var result = variables.model.getBalances( access_token = "secret-123" ); + expect( result ).toBeStruct( "should return deserialized JSON" ).toHaveKey( "balances" ); + } ); + } ); + } ); } } diff --git a/tests/specs/unit/AssetsTest.cfc b/tests/specs/unit/AssetsTest.cfc index e340022..757bef2 100755 --- a/tests/specs/unit/AssetsTest.cfc +++ b/tests/specs/unit/AssetsTest.cfc @@ -1,9 +1,9 @@ /** -* The base model test case will use the 'model' annotation as the instantiation path -* and then create it, prepare it for mocking and then place it in the variables scope as 'model'. It is your -* responsibility to update the model annotation instantiation path and init your model. -*/ -component extends="coldbox.system.testing.BaseModelTest" model="models.Assets"{ + * The base model test case will use the 'model' annotation as the instantiation path + * and then create it, prepare it for mocking and then place it in the variables scope as 'model'. It is your + * responsibility to update the model annotation instantiation path and init your model. + */ +component extends="coldbox.system.testing.BaseModelTest" model="models.Assets" { /*********************************** LIFE CYCLE Methods ***********************************/ @@ -24,12 +24,8 @@ component extends="coldbox.system.testing.BaseModelTest" model="models.Assets"{ /*********************************** BDD SUITES ***********************************/ function run(){ - describe( "Assets Suite", function(){ - - - }); - + } ); } } diff --git a/tests/specs/unit/TokensTest.cfc b/tests/specs/unit/TokensTest.cfc index 0c8a97d..881cbd8 100755 --- a/tests/specs/unit/TokensTest.cfc +++ b/tests/specs/unit/TokensTest.cfc @@ -1,9 +1,9 @@ /** -* The base model test case will use the 'model' annotation as the instantiation path -* and then create it, prepare it for mocking and then place it in the variables scope as 'model'. It is your -* responsibility to update the model annotation instantiation path and init your model. -*/ -component extends="coldbox.system.testing.BaseModelTest" model="models.Tokens"{ + * The base model test case will use the 'model' annotation as the instantiation path + * and then create it, prepare it for mocking and then place it in the variables scope as 'model'. It is your + * responsibility to update the model annotation instantiation path and init your model. + */ +component extends="coldbox.system.testing.BaseModelTest" model="models.Tokens" { /*********************************** LIFE CYCLE Methods ***********************************/ @@ -24,28 +24,23 @@ component extends="coldbox.system.testing.BaseModelTest" model="models.Tokens"{ /*********************************** BDD SUITES ***********************************/ function run(){ - xdescribe( "models.Tokens Suite", function(){ - it( "should createLink", function(){ expect( false ).toBeTrue(); - }); + } ); it( "should exchangeToken", function(){ expect( false ).toBeTrue(); - }); + } ); it( "should invalidateToken", function(){ expect( false ).toBeTrue(); - }); + } ); it( "should getLinkToken", function(){ expect( false ).toBeTrue(); - }); - - - }); - + } ); + } ); } } diff --git a/tests/specs/unit/Transactions.cfc b/tests/specs/unit/Transactions.cfc index c556a54..033dc8f 100644 --- a/tests/specs/unit/Transactions.cfc +++ b/tests/specs/unit/Transactions.cfc @@ -1,9 +1,9 @@ /** -* The base model test case will use the 'model' annotation as the instantiation path -* and then create it, prepare it for mocking and then place it in the variables scope as 'model'. It is your -* responsibility to update the model annotation instantiation path and init your model. -*/ -component extends="coldbox.system.testing.BaseModelTest" model="models.Transactions"{ + * The base model test case will use the 'model' annotation as the instantiation path + * and then create it, prepare it for mocking and then place it in the variables scope as 'model'. It is your + * responsibility to update the model annotation instantiation path and init your model. + */ +component extends="coldbox.system.testing.BaseModelTest" model="models.Transactions" { /*********************************** LIFE CYCLE Methods ***********************************/ @@ -24,15 +24,11 @@ component extends="coldbox.system.testing.BaseModelTest" model="models.Transacti /*********************************** BDD SUITES ***********************************/ function run(){ - describe( "cfplaid.models.Transactions Suite", function(){ - xit( "should getBalances", function(){ expect( false ).toBeTrue(); - }); - - }); - + } ); + } ); } -} \ No newline at end of file +}