mahdin70/codebert-devign-code-vulnerability-detector
Text Classification • 0.1B • Updated • 91
id int32 0 27.3k | func stringlengths 26 142k | target bool 2
classes | project stringclasses 2
values | commit_id stringlengths 40 40 | func_clean stringlengths 26 131k | vul_lines dict | normalized_func stringlengths 24 132k | lines sequencelengths 1 2.8k | label sequencelengths 1 2.8k | line_no sequencelengths 1 2.8k |
|---|---|---|---|---|---|---|---|---|---|---|
0 | static av_cold int vdadec_init(AVCodecContext *avctx)
{
VDADecoderContext *ctx = avctx->priv_data;
struct vda_context *vda_ctx = &ctx->vda_ctx;
OSStatus status;
int ret;
ctx->h264_initialized = 0;
/* init pix_fmts of codec */
if (!ff_h264_vda_decoder.pix_fmts) {
if (kCFC... | false | FFmpeg | 973b1a6b9070e2bf17d17568cbaf4043ce931f51 | static av_cold int vdadec_init(AVCodecContext *avctx)
{
VDADecoderContext *ctx = avctx->priv_data;
struct vda_context *vda_ctx = &ctx->vda_ctx;
OSStatus status;
int ret;
ctx->h264_initialized = 0;
if (!ff_h264_vda_decoder.pix_fmts) {
if (kCFCoreFoundationVersionNumber <... | {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
VDADecoderContext *ctx = avctx->priv_data;
struct vda_context *VAR_0 = &ctx->VAR_0;
OSStatus status;
int VAR_1;
ctx->h264_initialized = 0;
if (!ff_h264_vda_decoder.pix_fmts) {
if (kCFCoreFoundationVersionNumber < kCFCor... | [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"VDADecoderContext *ctx = avctx->priv_data;",
"struct vda_context *VAR_0 = &ctx->VAR_0;",
"OSStatus status;",
"int VAR_1;",
"ctx->h264_initialized = 0;",
"if (!ff_h264_vda_decoder.pix_fmts) {",
"if (kCFCoreFoundationVersionNumber < kCFCoreFoundati... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
21
],
[
23,
25
],
[
27,
29
],
[
31
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,... |
1 | static int transcode(AVFormatContext **output_files,
int nb_output_files,
InputFile *input_files,
int nb_input_files,
StreamMap *stream_maps, int nb_stream_maps)
{
int ret = 0, i, j, k, n, nb_ostreams = 0, step;
AVForma... | false | FFmpeg | 321b2a9ded0468670b7678b7c098886930ae16b2 | static int transcode(AVFormatContext **output_files,
int nb_output_files,
InputFile *input_files,
int nb_input_files,
StreamMap *stream_maps, int nb_stream_maps)
{
int ret = 0, i, j, k, n, nb_ostreams = 0, step;
AVForma... | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext **VAR_0,
int VAR_1,
InputFile *VAR_2,
int VAR_3,
StreamMap *VAR_4, int VAR_5)
{
int VAR_6 = 0, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12;
AVFormatContext *is, *os;
AVCodecCon... | [
"static int FUNC_0(AVFormatContext **VAR_0,\nint VAR_1,\nInputFile *VAR_2,\nint VAR_3,\nStreamMap *VAR_4, int VAR_5)\n{",
"int VAR_6 = 0, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11 = 0, VAR_12;",
"AVFormatContext *is, *os;",
"AVCodecContext *codec, *icodec;",
"OutputStream *ost, **ost_table = NULL;",
"InputStrea... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43
],
[
45
],
[
51
],
[
53
],
[... |
2 | static void v4l2_free_buffer(void *opaque, uint8_t *unused)
{
V4L2Buffer* avbuf = opaque;
V4L2m2mContext *s = buf_to_m2mctx(avbuf);
if (atomic_fetch_sub(&avbuf->context_refcount, 1) == 1) {
atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel);
if (s->reinit) {
... | false | FFmpeg | 5d5de3eba4c7890c2e8077f5b4ae569671d11cf8 | static void v4l2_free_buffer(void *opaque, uint8_t *unused)
{
V4L2Buffer* avbuf = opaque;
V4L2m2mContext *s = buf_to_m2mctx(avbuf);
if (atomic_fetch_sub(&avbuf->context_refcount, 1) == 1) {
atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel);
if (s->reinit) {
... | {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, uint8_t *VAR_1)
{
V4L2Buffer* avbuf = VAR_0;
V4L2m2mContext *s = buf_to_m2mctx(avbuf);
if (atomic_fetch_sub(&avbuf->context_refcount, 1) == 1) {
atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel);
if (s->reinit) {
if (!atom... | [
"static void FUNC_0(void *VAR_0, uint8_t *VAR_1)\n{",
"V4L2Buffer* avbuf = VAR_0;",
"V4L2m2mContext *s = buf_to_m2mctx(avbuf);",
"if (atomic_fetch_sub(&avbuf->context_refcount, 1) == 1) {",
"atomic_fetch_sub_explicit(&s->refcount, 1, memory_order_acq_rel);",
"if (s->reinit) {",
"if (!atomic_load(&s->ref... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
]
] |
4 | int av_opencl_buffer_write(cl_mem dst_cl_buf, uint8_t *src_buf, size_t buf_size)
{
cl_int status;
void *mapped = clEnqueueMapBuffer(gpu_env.command_queue, dst_cl_buf,
CL_TRUE,CL_MAP_WRITE, 0, sizeof(uint8_t) * buf_size,
0, NULL, NU... | false | FFmpeg | 57d77b3963ce1023eaf5ada8cba58b9379405cc8 | int av_opencl_buffer_write(cl_mem dst_cl_buf, uint8_t *src_buf, size_t buf_size)
{
cl_int status;
void *mapped = clEnqueueMapBuffer(gpu_env.command_queue, dst_cl_buf,
CL_TRUE,CL_MAP_WRITE, 0, sizeof(uint8_t) * buf_size,
0, NULL, NU... | {
"code": [],
"line_no": []
} | int FUNC_0(cl_mem VAR_0, uint8_t *VAR_1, size_t VAR_2)
{
cl_int status;
void *VAR_3 = clEnqueueMapBuffer(gpu_env.command_queue, VAR_0,
CL_TRUE,CL_MAP_WRITE, 0, sizeof(uint8_t) * VAR_2,
0, NULL, NULL, &status);
if (status != ... | [
"int FUNC_0(cl_mem VAR_0, uint8_t *VAR_1, size_t VAR_2)\n{",
"cl_int status;",
"void *VAR_3 = clEnqueueMapBuffer(gpu_env.command_queue, VAR_0,\nCL_TRUE,CL_MAP_WRITE, 0, sizeof(uint8_t) * VAR_2,\n0, NULL, NULL, &status);",
"if (status != CL_SUCCESS) {",
"av_log(&openclutils, AV_LOG_ERROR, \"Could not map Ope... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9,
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
5 | static int r3d_read_rdvo(AVFormatContext *s, Atom *atom)
{
R3DContext *r3d = s->priv_data;
AVStream *st = s->streams[0];
int i;
r3d->video_offsets_count = (atom->size - 8) / 4;
r3d->video_offsets = av_malloc(atom->size);
if (!r3d->video_offsets)
return AVERROR(ENOMEM);
f... | true | FFmpeg | aba232cfa9b193604ed98f3fa505378d006b1b3b | static int r3d_read_rdvo(AVFormatContext *s, Atom *atom)
{
R3DContext *r3d = s->priv_data;
AVStream *st = s->streams[0];
int i;
r3d->video_offsets_count = (atom->size - 8) / 4;
r3d->video_offsets = av_malloc(atom->size);
if (!r3d->video_offsets)
return AVERROR(ENOMEM);
f... | {
"code": [
" if (st->r_frame_rate.num)",
" (AVRational){st->r_frame_rate.den,",
" st->r_frame_rate.num},",
" if (st->r_frame_rate.num)"
],
"line_no": [
41,
45,
47,
41
]
} | static int FUNC_0(AVFormatContext *VAR_0, Atom *VAR_1)
{
R3DContext *r3d = VAR_0->priv_data;
AVStream *st = VAR_0->streams[0];
int VAR_2;
r3d->video_offsets_count = (VAR_1->size - 8) / 4;
r3d->video_offsets = av_malloc(VAR_1->size);
if (!r3d->video_offsets)
return AVERROR(ENOME... | [
"static int FUNC_0(AVFormatContext *VAR_0, Atom *VAR_1)\n{",
"R3DContext *r3d = VAR_0->priv_data;",
"AVStream *st = VAR_0->streams[0];",
"int VAR_2;",
"r3d->video_offsets_count = (VAR_1->size - 8) / 4;",
"r3d->video_offsets = av_malloc(VAR_1->size);",
"if (!r3d->video_offsets)\nreturn AVERROR(ENOMEM);",... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13
],
[
15
],
[
17,
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43,
45
],
[
47
],
[
49
],
[... |
6 | static int dds_decode(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
DDSContext *ctx = avctx->priv_data;
GetByteContext *gbc = &ctx->gbc;
AVFrame *frame = data;
int mipmap;
int ret;
ff_texturedsp_init(&ctx->texdsp);
bytestream2_init(gbc... | true | FFmpeg | afb4632cc30e83287338690c785ebac180436a59 | static int dds_decode(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
DDSContext *ctx = avctx->priv_data;
GetByteContext *gbc = &ctx->gbc;
AVFrame *frame = data;
int mipmap;
int ret;
ff_texturedsp_init(&ctx->texdsp);
bytestream2_init(gbc... | {
"code": [
" (frame->data[1][3+i*4]<<24)"
],
"line_no": [
227
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
DDSContext *ctx = VAR_0->priv_data;
GetByteContext *gbc = &ctx->gbc;
AVFrame *frame = VAR_1;
int VAR_4;
int VAR_5;
ff_texturedsp_init(&ctx->texdsp);
bytestream2_init(gbc, VAR... | [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"DDSContext *ctx = VAR_0->priv_data;",
"GetByteContext *gbc = &ctx->gbc;",
"AVFrame *frame = VAR_1;",
"int VAR_4;",
"int VAR_5;",
"ff_texturedsp_init(&ctx->texdsp);",
"bytestream2_init(gbc, VAR_3->VAR_1, VAR_3->V... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
25
],
[
27,
29
],
[
31
],
[
33
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
53
],
[... |
7 | static void check_lowpass_line(int depth){
LOCAL_ALIGNED_32(uint8_t, src, [SRC_SIZE]);
LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]);
LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]);
int w = WIDTH;
int mref = WIDTH_PADDED * -1;
int pref = WIDTH_PADDED;
int i, depth_byte;
... | true | FFmpeg | da032427786d9db4ab21014998cb1245083d6c85 | static void check_lowpass_line(int depth){
LOCAL_ALIGNED_32(uint8_t, src, [SRC_SIZE]);
LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]);
LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]);
int w = WIDTH;
int mref = WIDTH_PADDED * -1;
int pref = WIDTH_PADDED;
int i, depth_byte;
... | {
"code": [
"static void check_lowpass_line(int depth){",
" LOCAL_ALIGNED_32(uint8_t, src, [SRC_SIZE]);",
" LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]);",
" LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]);",
" int w = WIDTH;",
" int mref = WIDTH_PADDED * -1;",
... | static void FUNC_0(int VAR_0){
LOCAL_ALIGNED_32(uint8_t, src, [SRC_SIZE]);
LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]);
LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]);
int VAR_1 = WIDTH;
int VAR_2 = WIDTH_PADDED * -1;
int VAR_3 = WIDTH_PADDED;
int VAR_4, VAR_5;
Int... | [
"static void FUNC_0(int VAR_0){",
"LOCAL_ALIGNED_32(uint8_t, src, [SRC_SIZE]);",
"LOCAL_ALIGNED_32(uint8_t, dst_ref, [WIDTH_PADDED]);",
"LOCAL_ALIGNED_32(uint8_t, dst_new, [WIDTH_PADDED]);",
"int VAR_1 = WIDTH;",
"int VAR_2 = WIDTH_PADDED * -1;",
"int VAR_3 = WIDTH_PADDED;",
"int VAR_4, VAR_5;",
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
1,
1,
1,
0,
1,
0,
0
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21,
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
51
... |
9 | static void test_init(TestData *d)
{
QPCIBus *bus;
QTestState *qs;
char *s;
s = g_strdup_printf("-machine q35 %s %s",
d->noreboot ? "" : "-global ICH9-LPC.noreboot=false",
!d->args ? "" : d->args);
qs = qtest_start(s);
qtest_irq_intercep... | true | qemu | b4ba67d9a702507793c2724e56f98e9b0f7be02b | static void test_init(TestData *d)
{
QPCIBus *bus;
QTestState *qs;
char *s;
s = g_strdup_printf("-machine q35 %s %s",
d->noreboot ? "" : "-global ICH9-LPC.noreboot=false",
!d->args ? "" : d->args);
qs = qtest_start(s);
qtest_irq_intercep... | {
"code": [
" d->tco_io_base = qpci_legacy_iomap(d->dev, PM_IO_BASE_ADDR + 0x60);"
],
"line_no": [
53
]
} | static void FUNC_0(TestData *VAR_0)
{
QPCIBus *bus;
QTestState *qs;
char *VAR_1;
VAR_1 = g_strdup_printf("-machine q35 %VAR_1 %VAR_1",
VAR_0->noreboot ? "" : "-global ICH9-LPC.noreboot=false",
!VAR_0->args ? "" : VAR_0->args);
qs = qtest_star... | [
"static void FUNC_0(TestData *VAR_0)\n{",
"QPCIBus *bus;",
"QTestState *qs;",
"char *VAR_1;",
"VAR_1 = g_strdup_printf(\"-machine q35 %VAR_1 %VAR_1\",\nVAR_0->noreboot ? \"\" : \"-global ICH9-LPC.noreboot=false\",\n!VAR_0->args ? \"\" : VAR_0->args);",
"qs = qtest_start(VAR_1);",
"qtest_irq_intercept_in... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
13,
15,
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
41
],
[
45
],
[
49
],
[
53
],
[
55
]
] |
11 | void assert_avoptions(AVDictionary *m)
{
AVDictionaryEntry *t;
if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
exit(1);
}
}
| true | FFmpeg | 636ced8e1dc8248a1353b416240b93d70ad03edb | void assert_avoptions(AVDictionary *m)
{
AVDictionaryEntry *t;
if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
exit(1);
}
}
| {
"code": [
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(1);",
" exit(... | void FUNC_0(AVDictionary *VAR_0)
{
AVDictionaryEntry *t;
if ((t = av_dict_get(VAR_0, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
exit(1);
}
}
| [
"void FUNC_0(AVDictionary *VAR_0)\n{",
"AVDictionaryEntry *t;",
"if ((t = av_dict_get(VAR_0, \"\", NULL, AV_DICT_IGNORE_SUFFIX))) {",
"av_log(NULL, AV_LOG_FATAL, \"Option %s not found.\\n\", t->key);",
"exit(1);",
"}",
"}"
] | [
0,
0,
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
13 | "static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)\n\n{\n\n BDRVNBDState *s (...TRUNCATED) | true | qemu | a1d4e38a8b01a6699355c31867d524f8d4cd480e | "static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)\n\n{\n\n BDRVNBDState *s (...TRUNCATED) | {
"code": [],
"line_no": []
} | "static void FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1)\n\n{\n\n BDRVNBDState *s = VAR_0->opaq(...TRUNCATED) | ["static void FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1)\n{","BDRVNBDState *s = VAR_0->opaque;","(...TRUNCATED) | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [[1,3],[5],[7],[9],[11],[13],[17],[19],[21],[23],[25],[27],[29],[31],[33],[37],[41],[43,45,47],[49,5(...TRUNCATED) |
Original Paper: https://www.sciencedirect.com/science/article/abs/pii/S0167739X24004680
bibtex
@article{TRAN2024107504,
title = {DetectVul: A statement-level code vulnerability detection for Python},
journal = {Future Generation Computer Systems},
pages = {107504},
year = {2024},
issn = {0167-739X},
doi = {https://doi.org/10.1016/j.future.2024.107504},
url = {https://www.sciencedirect.com/science/article/pii/S0167739X24004680},
author = {Hoai-Chau Tran and Anh-Duy Tran and Kim-Hung Le},
keywords = {Source code vulnerability detection, Deep learning, Natural language processing},
abstract = {Detecting vulnerabilities in source code using graph neural networks (GNN) has gained significant attention in recent years. However, the detection performance of these approaches relies highly on the graph structure, and constructing meaningful graphs is expensive. Moreover, they often operate at a coarse level of granularity (such as function-level), which limits their applicability to other scripting languages like Python and their effectiveness in identifying vulnerabilities. To address these limitations, we propose DetectVul, a new approach that accurately detects vulnerable patterns in Python source code at the statement level. DetectVul applies self-attention to directly learn patterns and interactions between statements in a raw Python function; thus, it eliminates the complicated graph extraction process without sacrificing model performance. In addition, the information about each type of statement is also leveraged to enhance the model’s detection accuracy. In our experiments, we used two datasets, CVEFixes and Vudenc, with 211,317 Python statements in 21,571 functions from real-world projects on GitHub, covering seven vulnerability types. Our experiments show that DetectVul outperforms GNN-based models using control flow graphs, achieving the best F1 score of 74.47%, which is 25.45% and 18.05% higher than the best GCN and GAT models, respectively.}
}