I came accross this clang article for taint analysis:
In the article, it is mentioned that source and sink can be specified using a YAML file. Any idea how this YAML file can be provided to either scan-build or clang-tidy commands? I don't see a clear option that can be used with scan-build to provide this file. And, for clang-tidy, when I write that content in the .clang-tidy file, clang exists with error saying that it can't identify the 'Propagation' key.
For clang-tidy which comes with clang-17 on ubuntu 22.04 I tried
clang-tidy -checks alpha.security.taint.TaintPropagation ../llvmTaintAnalysis.c
It doesn't report any errors, but it doesn't show the analysis result since, I am not able to define the source/sink of the taint.
Here is the code that I need to test, the source is the argument of the function update_len_value, and the sink is the argument of the function update_len_here.
#include <stdio.h>
#define MAX_SIZE 4
struct s_len_t {
unsigned int *plen;
};
struct s_s_len_t {
struct s_len_t *s_len;
};
void update_len_here(unsigned int *plen4)
{
*plen4 = 1000;
}
void intermediate3(unsigned int *plen3)
{
update_len_here(plen3);
}
void intermediate2(unsigned int *plen2)
{
intermediate3(plen2);
}
void intermediate1(struct s_len_t *s_len)
{
intermediate2(s_len->plen);
}
void update_len_value(struct s_s_len_t *s_s_len)
{
intermediate1(s_s_len->s_len);
}
int main()
{
unsigned int var = 5;
struct s_len_t s_len;
struct s_s_len_t s_s_len = {.s_len = &s_len};
struct s_s_len_t *p_s_s_len = &s_s_len;
p_s_s_len->s_len->plen = &var;
update_len_value(p_s_s_len);
char srcArray[MAX_SIZE] = {0};
char destArray[MAX_SIZE] = {0};
for (int i = 0; i < *p_s_s_len->s_len->plen; i++) {
destArray[i] = srcArray[i];
}
return destArray[0];
}