Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Compliant and NonCompliant DL cases for C language #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sanjuera
Copy link

@sanjuera sanjuera commented Nov 6, 2024

Added non compliant and compliant samples for C detectors.

Note: All the test cases have 100% recall and precision.


int compliant() {
//Compliant : using `strsep_s()` can leads to crashes or security issues.
char *static_str = "message,token";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the example here. Some mismatch.

#include <stdlib.h>

void noncompliant() {
//NonCompliant : using `strtok()` tokenises strings safely via pointer without altering the original and also supports thread-safe parsing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some mismatch between compliant and non compliant

int compliant(){
//Compliant : Ensuring proper allocation and deallocation procedures.
int initial = 1000;
struct data *data = malloc(sizeof(*data));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you cal the variable data_pointer
So,

struct data *data_ptr = malloc(sizeof(*data_ptr));


int noncompliant() {
//NonCompliant : Avoid using `sscanf()` for number conversions.
const char *float_str = "3.1415926535897932384626433832";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the length of the float be changed "3.14159" should be enough

#include <stdio.h>

void compliant() {
//Compliant : Using `scanf()` explicitly null terminate buffer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is not clear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants