- ALM used : GitHub
- CI system used: Github Actions
- Scanner command used when applicable (private details masked):
sonar-scanner --define sonar.projectKey=balaji-nordic_unit-test-experiments
–define sonar.organization=balaji-nordic
–define sonar.host.url=“${{ env.SONAR_SERVER_URL }}”
–define sonar.exclusions=“CMakeFiles”
–define sonar.cpd.exclusions=“CMakeFiles”
–define sonar.cfamily.build-wrapper-output=“${{ env.BUILD_WRAPPER_OUT_DIR }}”
–define sonar.cfamily.gcov.reportsPath=“gcov_reports_dir” - Languages of the repository: C
- Only if the SonarCloud project is public, the URL : https://sonarcloud.io/project/overview?id=balaji-nordic_unit-test-experiments
- And if you need help with pull request decoration, then the URL to the PR too : Test if sonarcloud finds this by balaji-nordic · Pull Request #28 · balaji-nordic/unit-test-experiments · GitHub
- Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
I expect sonarcloud to warn about unguarded access to the memory that may result in possible memory overwrite. But it does not seem to do that unless I write a test case that actually makes the memory violation happen. - Steps to reproduce:
#define SIZE_OF_ARRAY 2
int array[SIZE_OF_ARRAY];
int insert_in_array(int pos)
{
array[pos] = 1;
return 0;
}
A call to insert_in_array(1)
does not result in any bug reports. But insert_in_array(4)
does result in the expected bug report. I expect sonarcloud to atleast warn about the unguarded memory access irrespective whether the function is called with arguments that lead to the manifestation of the bug as the function insert_in_array() is a public function.