Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,28 @@ on:

env:
build: '${{ github.workspace }}/build'
config: 'Debug'
result: '${{ github.workspace }}/build/results.sarif'

jobs:
build:
name: Run Analysis
name: Analyze
runs-on: windows-latest

steps:
- name: Checkout action
uses: actions/checkout@v2.3.4

- name: Initialize & Build
uses: lukka/run-cmake@v3
with:
cmakeListsTxtPath: ${{ github.workspace }}/CMakeLists.txt
buildDirectory: ${{ env.build }}
cmakeGenerator: VS16Win64
- name: Configure CMake
run: cmake -B ${{ env.build }} -DCMAKE_BUILD_TYPE=${{ env.config }}

- name: Run Analysis
id: run-analysis
continue-on-error: true
uses: microsoft/msvc-code-analysis-action@main
id: run-analysis
with:
cmakeBuildDirectory: ${{ env.build }}
buildConfiguration: ${{ env.config }}
ruleset: All.ruleset
ignoreSystemHeaders: true

- name: Upload SARIF to Github
uses: github/codeql-action/upload-sarif@v1
Expand Down
1 change: 1 addition & 0 deletions All.ruleset
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Ruleset to test out github actions" Description="Currently only targetting CppCoreCheck." ToolsVersion="16.0">
<Rules AnalyzerId="Microsoft.Analyzers.NativeCodeAnalysis" RuleNamespace="Microsoft.Rules.Native">
<Rule Id="C6011" Action="Warning" />
<Rule Id="C26400" Action="Warning" />
<Rule Id="C26401" Action="Warning" />
<Rule Id="C26402" Action="Warning" />
Expand Down
37 changes: 26 additions & 11 deletions Cppcorecheck/CppCoreCheck.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
// ConsoleApp.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
// Trigger new workflow...

// update...
#include <iostream>
#include <optional>

int main()
{
int* p = 0;
int q = 1;
if (q)
{
return *(p + 1);
}
return 0;
}

std::optional<int> getTempOptional() noexcept { return {}; }

void RefrenceToTemp() noexcept
{
if (const auto val = *getTempOptional()) // C26815
{
(void)val;
}
}

void RawPointerAssignment() {
// C26400: No Raw Pointer Assignment (r.11)
// C26409: Avoid call new or delete explicitly (r.11)
//char* buffer = new char[30];
char* buffer = new char[30];

// BUG: FIX
// C26481: Don't use pointer arithmetic. Use span instead (bounds.1)
//buffer[0] = 'a';
buffer[0] = 'a';
}

int NullDereference()
{
const int* p = 0;
const int q = 1;
if (q)
{
return *(p + 1);
}
return 0;
}

struct MyStruct {
Expand Down