diff --git a/.github/workflows/branch1.yml b/.github/workflows/branch1.yml new file mode 100644 index 0000000..9849586 --- /dev/null +++ b/.github/workflows/branch1.yml @@ -0,0 +1,136 @@ +name: C/C++test with Make + +on: + # Triggers the workflow on push or pull request events but only for the master (main) branch. + push: + #branches: [ main, main ] + #branches: [ main ] + branches: [ branch1 ] + pull_request: + #branches: [ main, main ] + #branches: [ main ] + branches: [ branch1 ] + + # Allows you to run this workflow manually from the Actions tab. + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel. +jobs: + run-cpptest-make: + name: Analyze project with C/C++test + + # Specifies required permissions for upload-sarif action + permissions: + # required for all workflows + security-events: write + # only required for workflows in private repositories + actions: read + contents: read + + # Specifies the type of runner that the job will run on. + runs-on: self-hosted + + # Steps represent a sequence of tasks that will be executed as part of the job. + steps: + + # Checks out your repository under $GITHUB_WORKSPACE, so that your job can access it. + #- name: Checkout code + # uses: actions/checkout@v4 + + # Builds your Make project using 'cpptesttrace' to collect input data for code analysis. + # Be sure 'cpptesttrace' is available on $PATH. + #- name: Build project + # run: cpptesttrace make clean all + - name: Checkout repository + # Use the 'run-cpptest-action' GitHub action. + uses: actions/checkout@v4 + with: + #ref: 'branch1' + fetch-depth: 0 + + # Runs code analysis with C/C++test. + #- name: show CppTest settings + #shell: cmd + # + # run: 'cpptestcli -data d:\workspace\github\cpptest_runner -resource ATM -config "user://MISRA C 2023 (MISRA C 2012) files modify or added" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1_runner.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + # issue with naming of branch in Test configuration + #run: 'cpptestcli -data d:\workspace\github\cpptest_runner -resource ATM -config "user://MISRA C 2023 (MISRA C 2012) branch1 main" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1_runner.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + # works fine + #run: 'cpptestcli -data d:\workspace\github\cpptest_runner -resource ATM -config "builtin://MISRA C 2023 (MISRA C 2012)" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1_runner.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + # works fine + #run: '"C:\Parasoft\cpptest\2025.2_standalone\cpptestcli.exe" -data d:\workspace\github\cpptest_runner -resource ATM -config "builtin://MISRA C 2023 (MISRA C 2012)" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1_runner.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + # issue with branch + #run: '"C:\Parasoft\cpptest\2025.2_standalone\cpptestcli.exe" -data d:\workspace\github\cpptest_runner -resource ATM -config "user://MISRA C 2023 (MISRA C 2012) branch1 main" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1_runner.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + # issue with branch + #run: '"C:\Parasoft\cpptest\2025.2_standalone\cpptestcli.exe" -data d:\workspace\github\cpptest2025.2_runner -resource ATM -config "user://MISRA C 2023 (MISRA C 2012) branch1 main" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.2_runner.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + # branch issue + #run: '"c:\Parasoft\cpptest\2025.2_standard\cpptestcli.exe" -input "d:\workspace\github\cpptest2025.2standard_runner\ATM\ATM_github.bdf" -compiler gcc_9-64 -config "C:\Parasoft\cpptest\2025.2_standard\configs\user\MISRA C 2023 (MISRA C 2012) branch1 main.properties"' + # branch issue + # run: '"c:\Parasoft\cpptest\2025.2_standard\cpptestcli.exe" -showdetails -show-settings' + + #- name: Run C/C++test in shell + #shell: cmd + # + # run: 'cpptestcli -data d:\workspace\github\cpptest_runner -resource ATM -config "user://MISRA C 2023 (MISRA C 2012) files modify or added" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1_runner.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + # issue with naming of branch in Test configuration + #run: 'cpptestcli -data d:\workspace\github\cpptest_runner -resource ATM -config "user://MISRA C 2023 (MISRA C 2012) branch1 main" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1_runner.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + # works fine + #run: 'cpptestcli -data d:\workspace\github\cpptest_runner -resource ATM -config "builtin://MISRA C 2023 (MISRA C 2012)" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1_runner.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + # works fine + #run: '"C:\Parasoft\cpptest\2025.2_standalone\cpptestcli.exe" -data d:\workspace\github\cpptest_runner -resource ATM -config "builtin://MISRA C 2023 (MISRA C 2012)" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1_runner.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + # issue with branch + #run: '"C:\Parasoft\cpptest\2025.2_standalone\cpptestcli.exe" -data d:\workspace\github\cpptest_runner -resource ATM -config "user://MISRA C 2023 (MISRA C 2012) branch1 main" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1_runner.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + # issue with branch + #run: '"C:\Parasoft\cpptest\2025.2_standalone\cpptestcli.exe" -data d:\workspace\github\cpptest2025.2_runner -resource ATM -config "user://MISRA C 2023 (MISRA C 2012) branch1 main" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.2_runner.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + # branch issue + #run: '"c:\Parasoft\cpptest\2025.2_standard\cpptestcli.exe" -input "d:\workspace\github\cpptest2025.2standard_runner\ATM\ATM_github.bdf" -compiler gcc_9-64 -config "C:\Parasoft\cpptest\2025.2_standard\configs\user\MISRA C 2023 (MISRA C 2012) branch1 main.properties"' + # branch issue + #run: '"c:\Parasoft\cpptest\2025.2_standard\cpptestcli.exe" -input "d:\workspace\github\cpptest2025.2standard_runner\ATM\ATM_github.bdf" -compiler gcc_9-64 -config "C:\Parasoft\cpptest\2025.2_standard\configs\builtin\MISRA C 2023 (MISRA C 2012).properties" -showdetails' + # branch issue + #run: '/home/sgrabinski/cpptest/2025.2_standard/cpptestcli -input "/home/sgrabinski/workspace2025.2_standard/ATM/ATM_github.bdf" -compiler gcc_9-64 -config "/home/sgrabinski/cpptest/2025.2_standard/configs/builtin/MISRA C 2023 (MISRA C 2012).properties" -showdetails' + + #commandLinePattern: '${cpptestcli} -data d:\workspace\github\cpptest_runner -resource ATM -config "builtin://MISRA C 2023 (MISRA C 2012)" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1.properties" -property "report.format=sarif"' + + - name: Run C/C++test in shell + shell: bash + #working-directory: /home/sgrabinski/workspace2025.2_standard + # works with branch but with below setup in properties file: + # scontrol.rep1.type=git + # scope.scontrol=true + # scope.scontrol.files.filter.mode=branch + # scope.scontrol.ref.branch=main + # scontrol.rep1.git.branch=branch1 + # scontrol.rep1.git.url=https\://github.com/stingerBoo/ATM.git + # scontrol.rep1.git.workspace=/home/sgrabinski/workspace2025.2_standard/ATM/ + #run: 'sudo -S <<< "password" /home/sgrabinski/cpptest/2025.2_standard/cpptestcli -input "/home/sgrabinski/workspace2025.2_standard/ATM/ATM_github.bdf" -compiler gcc_9-64 -config "/home/sgrabinski/cpptest/2025.2_standard/configs/builtin/MISRA C 2023 (MISRA C 2012).properties" -showdetails' + # + #run: 'sudo /home/sgrabinski/cpptest/2025.2_standard/cpptestcli -input "/home/sgrabinski/workspace2025.2_standard/ATM/ATM_github.bdf" -compiler gcc_9-64 -config "/home/sgrabinski/cpptest/2025.2_standard/configs/user/MISRA C 2023 (MISRA C 2012) branch1 main.properties" -showdetails' + # + run: 'sudo /home/sgrabinski/cpptest/2025.2_standard/cpptestcli -input "/home/sgrabinski/workspace2025.2_standard/ATM/ATM_github.bdf" -compiler gcc_9-64 -config "/home/sgrabinski/cpptest/2025.2_standard/configs/user/MISRA C 2023 (MISRA C 2012) branch1 main.properties" -showdetails' + + + # Runs code analysis with C/C++test. + #- name: Run C/C++test + # Use the 'run-cpptest-action' GitHub action. + #uses: parasoft/run-cpptest-action@2.0.2 + #with: + # + #additionalParams: "-J-Dscontrol.log=true" + #commandLinePattern: '${cpptestcli} -data d:\workspace\github\cpptest_runner -resource ATM -config "user://MISRA C 2023 (MISRA C 2012) branch1 main" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1.properties" -property "report.format=sarif" -appconsole stdout -showdetails' + #commandLinePattern: '${cpptestcli} -data d:\workspace\github\cpptest_runner -resource ATM -config "builtin://MISRA C 2023 (MISRA C 2012)" -report "_report" -localsettings "d:\workspace\cpptest\cpptest2025.1.properties" -property "report.format=sarif"' + #commandLinePattern: '${cpptestcli} -input "d:\workspace\github\cpptest2025.2standard_runner\ATM\ATM_github.bdf" -compiler gcc_9-64 -config "C:\Parasoft\cpptest\2025.2_standard\configs\builtin\MISRA C 2023 (MISRA C 2012).properties" -showdetails' + + # Uploads analysis results in the SARIF format, so that they are displayed as GitHub code scanning alerts. + - name: Upload results (SARIF) + if: always() + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: _report/report.sarif + + # Uploads an archive that includes all report files (.xml, .html, .sarif). + - name: Archive reports + if: always() + uses: actions/upload-artifact@v4 + with: + name: Static analysis reports + path: _report/*.* diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 4d76a30..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: C/C++test with Make - -on: - # Triggers the workflow on push or pull request events but only for the master (main) branch. - push: - branches: [ master, main ] - pull_request: - branches: [ master, main ] - - # Allows you to run this workflow manually from the Actions tab. - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel. -jobs: - run-cpptest-make: - name: Analyze project with C/C++test - - # Specifies required permissions for upload-sarif action - permissions: - # required for all workflows - security-events: write - # only required for workflows in private repositories - actions: read - contents: read - - # Specifies the type of runner that the job will run on. - runs-on: self-hosted - - # Steps represent a sequence of tasks that will be executed as part of the job. - steps: - - # Checks out your repository under $GITHUB_WORKSPACE, so that your job can access it. - #- name: Checkout code - # uses: actions/checkout@v4 - - # Builds your Make project using 'cpptesttrace' to collect input data for code analysis. - # Be sure 'cpptesttrace' is available on $PATH. - #- name: Build project - # run: cpptesttrace make clean all - - # Runs code analysis with C/C++test. - - name: Run C/C++test - # Use the 'run-cpptest-action' GitHub action. - uses: parasoft/run-cpptest-action@2.0.2 - with: - # To enable SARIF reporting, put additional configuration entries into config.properties file: - # - for C/C++test 2021.1 or newer - using built-in SARIF reporting: - # report.format=sarif - # - for older versions of C/C++test - using legacy SARIF reporting: - # report.format=custom - # report.custom.extension=sarif - # report.custom.xsl.file=${PARASOFT_SARIF_PRO_XSL} - # report.location_details=true - # additionalParams: '-localsettings config.properties' - # commandLinePattern: '${cpptestcli} -data ../workspace -config "builtin://Recommended Rules" -report "$_report/" ${additionalParams}' - commandLinePattern: '${cpptestcli} -data d:\workspace\2024.1 -resource ATM -config "builtin://SEI CERT C Guidelines" -report "_report" -localsettings "D:\workspace\cpptest2024.1.properties" -property "report.format=sarif"' - - # Uploads analysis results in the SARIF format, so that they are displayed as GitHub code scanning alerts. - - name: Upload results (SARIF) - if: always() - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: _report/report.sarif - - # Uploads an archive that includes all report files (.xml, .html, .sarif). - - name: Archive reports - if: always() - uses: actions/upload-artifact@v4 - with: - name: Static analysis reports - path: _report/*.* diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 725172d..d5fb6e7 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -4,8 +4,8 @@ - - + + diff --git a/ATM.cxx b/ATM.cxx index ef323e2..e6e50c9 100644 --- a/ATM.cxx +++ b/ATM.cxx @@ -14,6 +14,16 @@ void ATM::viewAccount(int accountNumber, string password) myDisplay->showInfoToUser("Invalid account"); // } + if ( !(myCurrentAccount = myBank->getAccount(accountNumber, password)) ) + { + myDisplay->showInfoToUser("Invalid account"); + // + } + if ( !(myCurrentAccount = myBank->getAccount(accountNumber, password)) ) + { + myDisplay->showInfoToUser("Invalid account"); + // + } } void ATM::fillUserRequest(UserRequest request, double amount)