Checkmarx.API 6.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Checkmarx.API --version 6.0.0                
NuGet\Install-Package Checkmarx.API -Version 6.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Checkmarx.API" Version="6.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Checkmarx.API --version 6.0.0                
#r "nuget: Checkmarx.API, 6.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Checkmarx.API as a Cake Addin
#addin nuget:?package=Checkmarx.API&version=6.0.0

// Install Checkmarx.API as a Cake Tool
#tool nuget:?package=Checkmarx.API&version=6.0.0                

Checkmarx.API

The goal of this project is to provide an API Wrapper for the Checkmarx SAST (REST, SOAP and OData API) for .NET Core to works in a transparent way between the different the Checkmarx versions (8.9 or Higher)

It currently already supports the Checkmarx SCA (Software Composition Analysis),

Future Support: (Access Control & IAST) support.

Running the Unit Tests

Before running the unit tests please make sure to configure the needed credentials using the Safe storage of app secrets in development in ASP.NET Core

How to use the SDK

Connection to SAST or SCA

A CxClient provider access to SAST and an SCAClient provides access to SCA:

// create a SAST client to interact with SAST/OSA and the Access Control (AC)
CxClient sastClient = new CxClient(new Uri("https://sast.server.com"),
                        "my_user",
                        "mypassword");

// create a SCA client to interact with SCA and the Access Control (AC)
SCAClient scaClient = new SCAClient(Tenant, Username, Password);

Check the version of Checkmarx Product

Console.WriteLine(sastClient.Version);

Check the version of Checkmarx Product without authentication

Console.WriteLine(CxClient.GetVersionWithoutConnecting("https://sastserver"));

Get the Access Control from SAST

AccessControlClient accessControlClient = sastClient.AC;

Get the Access Control from SCA

AccessControlClient accessControlClient = scaClient.AC;

SAST (Security Application Security Testing)

Check the Checkmarx.API.Tests.CxClientUnitTests.cs for a lot of code snippets on how to use the API.

List projects

foreach (var item in sastClient.GetProjects())
{
    Trace.WriteLine(item.Value);
}    

Create Project

sastClient.SASTClient.ProjectsManagement_PostByprojectAsync(new SaveProjectDto {
                IsPublic = true, 
                Name = "ProjectName",
                OwningTeam = "34"
}).Wait();

Branch Project

sastClient.SASTClient.BranchProjects_BranchByidprojectAsync(123, new BranchProjectDto
            {
                Name = "New Branch Name"
            }).Wait();

Run Scan

client.RunSASTScan(projectId, null, true, sourceCodeZipFile);

Presets

Reports

SCA (Software Compostion Analysis)

Check the Checkmarx.API.Tests.SCAClientUnitTests.cs for a lot of code snippets on how to use the API.

List projects

foreach (var project in scaClient.ClientSCA.GetProjectsAsync().Result)
{
    Console.WriteLine(project.Id + "  " + project.Name);
}

Create Project

 var scaProject = scaClient.ClientSCA.CreateProjectAsync(new API.SCA.CreateProject
 {
     Name = scaProjectName,
     AssignedTeams = new string[] { teamFullPath }
 }).Result;

Trigger Scan with Zip Source Code

scaClient.ScanWithSourceCode(scaProject.Id, zipPath);

Access Control API

Get/List All Users

foreach (var user in accessControlClient.GetAllUsersDetailsAsync().Result)
{
     Console.WriteLine(user.Email + string.Join(";", user.TeamIds.Select(x => teamsx].FullName)) +" "  user.LastLoginDate);

     foreach (var role in user.RoleIds.Select(x => roles[x].Name))
     {
         Console.WriteLine("+ " + role);
     }
}

Create a new user

ICollection<int> cxTamRoles = new int[] {
    accessControlClient.RolesAllAsync().Result.First(x => x.Name == "SAST Admin").Id
};

ICollection<int> cxTeamIds = new int[] {
    accessControlClient.TeamsAllAsync().Result.First(x => x.FullName == "/CxServer").Id
};

int localeID = accessControlClient.SystemLocalesAsync().Result.First(x => x.Code == "enUS").Id;

CreateUserModel user = new CreateUserModel
{
    FirstName = "firstname",
    LastName = "lastname",
    UserName = "email@checkmarx.com",
    Email = "email@checkmarx.com",
    Password = "******",
    ExpirationDate = DateTimeOffset.UtcNow + TimeSpan.FromDays(1000),
    Active = true,

    Country = "Portugal",
    JobTitle = "The World Greatest",

    AuthenticationProviderId = accessControlClient.AuthenticationProvidersAsyn().Result.First(X =>X.Name == "Application").Id, // Application User

    LocaleId = localeID,
    RoleIds = cxTamRoles,
    TeamIds = cxTeamIds,

};

accessControlClient.CreatesNewUser(user).Wait();

Get/List Teams

foreach (var item in accessControlClient.TeamsAllAsync().Result)
{
    Console.WriteLine($"{item.Id} = {item.FullName}");
}

Get or Create Team

scaClient.AC.GetOrCreateTeam(teamFullPath);
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.1.0 110 8/5/2024
6.0.0 91 7/10/2024
5.1.0 136 3/22/2024
5.0.0 123 3/1/2024
4.0.0 165 1/27/2024
3.6.0 180 8/18/2023
3.5.0 195 7/10/2023
3.4.0 376 11/17/2022
3.3.0 354 11/2/2022
3.2.0 419 10/19/2022
3.1.0 395 10/19/2022
3.0.0 407 10/19/2022
2.9.0 381 10/6/2022
2.8.0 348 10/5/2022
2.7.0 431 8/16/2022
2.6.1 453 4/16/2022
2.5.0 416 3/24/2022
2.4.0 417 3/24/2022
2.3.0 353 1/2/2022
2.2.0 278 1/2/2022
2.1.0 3,531 11/25/2021
2.0.0 392 11/5/2021
1.6.0 381 11/5/2021
1.5.0 379 8/27/2021
1.0.0 387 7/25/2021
0.1.1 390 1/25/2021
0.1.0 347 1/25/2021