PricingDownload
Product

Platform

All features44 capabilities, from IDE to CICompliance KitsISO 26262, DO-178C, IEC 62304...AI GovernanceControl AI-generated C/C++ codeWhat’s new in 2027Latest version highlightsScreenshotsSee the product in action

Analyze & improve

Coding standardsMISRA, CERT, CWE, AUTOSARArchitecture & dependenciesGraphs, matrix, cyclesTechnical debtMeasured in hours and dollarsQuality gatesStop regressions in CISmart Code CityYour codebase in 3D

Integrations

IDE pluginsVisual Studio, VS Code, CLion...CI/CD pipelinesJenkins, Azure DevOps, GitHub, GitLabSonarQube pluginC/C++ results in SonarQubeExternal analyzersClang-Tidy, Cppcheck, coverageFeature on Demand
Solutions

By need

Functional safetyCompliance kits per standardCoding standardsMISRA, CERT, AUTOSAR, ISO...Legacy modernizationRefactor large C/C++ safelyCode auditExpert review of your codebaseM&A due diligenceAssess technical health fast

By role

DevelopersSoftware architectsTech leadsDevOps engineersEngineering managersProject managers

CTOsCIOs / IT leadersQA engineersSecurity leadersComplianceConsultantsRequest a guided PoC
Industries

Safety-critical

AutomotiveISO 26262, MISRA, AUTOSARAerospace & DefenseDO-178C programsMedical DevicesIEC 62304 softwareEnergy & UtilitiesIEC 61508 systemsEmbedded SystemsFirmware and devices

Enterprise

Financial ServicesTrading and paymentsGame DevelopmentEngines and large C++Software VendorsCommercial C/C++ productsGovernmentAgencies and contractorsAll industries & case studies
Resources

Learn

DocumentationGuides, rules and CI setupKnowledge baseFrequently asked questionsBlogC and C++ code quality articlesRelease notesEvery version since 2009

Customers

Case studiesSuccess storiesTestimonialsWhat users sayOur customersCompanies using CppDependGold Code QualityOpen source projects we rate

Programs & company

Feature on DemandMissing features built for freeFree for open sourceLicenses for OSS and studentsContact usSales and supportEULALicense agreement
Docs
Documentation

Coding Standards

Ensure CWE Compliance and Strengthen C/C++ Code Security using CppDepend

4 min readCoding StandardsCppDepend 2027

In the world of software development, adhering to secure coding practices is crucial for protecting applications and systems from potential threats. Achieving CWE (Common Weakness Enumeration) compliance is an essential step in this process. CPPDepend offers a robust solution for C/C++ developers to ensure CWE compliance, effectively strengthening code security and overall software quality.

In this guide, we will explore the benefits of using CPPDepend for CWE compliance, including its powerful features for identifying and mitigating vulnerabilities, enhancing code quality, and promoting secure coding practices in your C/C++ projects.

Using CWE Rules in CppDepend

When you create a new CppDepend Project, a pop-up will appear displaying all the coding standards you would like to include in your analysis. To include CWE coding standards, check the CWE option.

CWE Rules Configuration

After analyzing your project, Navigate to the Queries and Rules Explorer section, and select the CWE Rules from the left-hand menu (Highlighted in red in the image below). This will display all the related CWE rules on the right. Upon clicking a Rule, the corresponding CQLinq query and the relevant source code will be automatically generated. Additionally, the Metrics View section provides a visualization of the issue location and significance.

CWE Rules Explorer

Incorporating CWE Rules into the HTML Report

To include the CWE rules in the generated HTML Report (available in the DevOps Edition), simply right-click on the CWE group and select "List Code Queries of this Group in a dedicated section in Report."

CWE Rules in Report

CWE Rules

Buffer Copy without Checking Size of Input ('Classic Buffer Overflow'):

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck"
&& (issue.Type=="bufferAccessOutOfBounds" || issue.Type=="possibleBufferAccessOutOfBounds"
|| issue.Type=="insecureCmdLineArgs"|| issue.Type=="invalidscanf") select
new { issue,issue.FilePath,Line=issue.BeginLine}

Divide By Zero:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="zerodiv"  select
new { issue,issue.FilePath,Line=issue.BeginLine}

Unchecked Error Condition:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="zerodiv"  select
new { issue,issue.FilePath,Line=issue.BeginLine}

Declaration of Catch for Generic Exception:

This coding standard is computed with the following query:

warnif **count** > **0**
from m in **Methods** where !m.IsEntryPoint
&& m.IsUsing("Keywords.generic_catch".AllowNoMatch()) select m

Improper Release of Memory Before Removing Last Reference ('Memory Leak'):

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && (issue.Type=="memleak" || issue.Type=="memleakOnRealloc"
|| issue.Type=="publicAllocationError"|| issue.Type=="leakNoVarFunctionCall") select
new { issue,issue.FilePath,Line=issue.BeginLine}

Double Free:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="deallocDealloc"  select
new { issue,issue.FilePath,Line=issue.BeginLine}

Use of Uninitialized Variable:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="uninitvar"
select new { issue, issue.FilePath, Line = issue.BeginLine ,
Debt = **10**.ToMinutes().ToDebt(),
Severity =Severity.High
}

Incomplete Cleanup:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="resourceLeak"  select
new { issue,issue.FilePath,Line=issue.BeginLine}

NULL Pointer Dereferenced:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="nullPointer"  select
new { issue,issue.FilePath,Line=issue.BeginLine}

Use of Obsolete Functions:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CLang" && issue.Type=="warn_deprecated"  select
new { issue,issue.FilePath,Line=issue.BeginLine}

Comparing instead of Assigning:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="CLang" && issue.Type=="warn_unused_comparison"  select
new { issue,issue.FilePath,Line=issue.BeginLine}

Omitted Break Statement in Switch:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_unannotated_fallthrough" select
new { issue,issue.FilePath,Line=issue.BeginLine}

Dead Code:

This coding standard is computed with the following query:

warnif **count** > **0**
from issue in **ImportedIssues** where issue.ToolName=="Clang" && issue.Type=="warn_unreachable" select
new { issue,issue.FilePath,Line=issue.BeginLine}

Assignment to Variable without Use ('Unused Variable'):

This coding standard is computed with the following query:

warnif **count** > **0** from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="unreadVariable"
select new { issue, issue.FilePath, Line = issue.BeginLine ,
Debt = **2**.ToMinutes().ToDebt(),
Severity =Severity.Low
}

Expression is Always False:

This coding standard is computed with the following query:

warnif **count** > **0** from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="knownConditionTrueFalse"
&& issue.Description.Contains("always false")
select new { issue, issue.FilePath, Line = issue.BeginLine ,
Debt = **2**.ToMinutes().ToDebt(),
Severity =Severity.Low
}

Expression is Always True:

This coding standard is computed with the following query:

warnif **count** > **0** from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="knownConditionTrueFalse"
&& issue.Description.Contains("always true")
select new { issue, issue.FilePath, Line = issue.BeginLine ,
Debt = **2**.ToMinutes().ToDebt(),
Severity =Severity.Low
}

Function Call with Incorrectly Specified Arguments:

This coding standard is computed with the following query:

warnif **count** > **0** from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="preprocessorErrorDirective"
&& issue.Description.Contains("Wrong number")
select new { issue, issue.FilePath, Line = issue.BeginLine ,
Debt = **2**.ToMinutes().ToDebt(),
Severity =Severity.Low
}

Use of Potentially Dangerous Function:

This coding standard is computed with the following query:

warnif **count** > **0** from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && issue.Type=="dangerousUsageStrtol"
select new { issue, issue.FilePath, Line = issue.BeginLine ,
Debt = **2**.ToMinutes().ToDebt(),
Severity =Severity.Low
}

Operator Precedence Logic Error:

This coding standard is computed with the following query:

warnif **count** > **0** from issue in **ImportedIssues** where issue.ToolName=="CppCheck" && (issue.Type=="clarifyCalculation"
|| issue.Type=="clarifyCondition")
select new { issue, issue.FilePath, Line = issue.BeginLine ,
Debt = **2**.ToMinutes().ToDebt(),
Severity =Severity.Low
}
Was this page helpful?
Evaluating CppDepend on a production codebase?Get a guided proof of concept with our static analysis architects.
Request a PoC