[LTP] [PATCH] metadata: automatically detect CVE via tags
Cyril Hrubis
chrubis@suse.cz
Mon Jun 22 15:31:00 CEST 2026
Hi!
> /*
> - * Add a group to the groups array, skipping 'kernel' as it's too generic.
> - * Returns 0 if no group was added, 1 otherwise.
> + * Add a group to the groups array, skipping path components that are too
> + * generic ('kernel') or assigned from a more reliable source ('cve', which
> + * is derived from the CVE tag instead). Returns 0 if no group was added,
> + * 1 otherwise.
> */
> static int add_group(struct data_node *groups, const char *name)
> {
> - if (name && strcmp(name, "kernel")) {
> + if (name && strcmp(name, "kernel") && strcmp(name, "cve")) {
> data_node_array_add(groups, data_node_string(name));
> return 1;
> }
> @@ -971,11 +973,11 @@ static void load_internal_macros(void)
> * Add groups derived from the source file path.
> *
> * Groups are the two nearest parent directories (immediate parent
> - * first), skipping 'kernel' as it's too generic:
> + * first), skipping 'kernel' (too generic) and 'cve' (assigned from the
> + * CVE tag instead, see add_tag_groups()):
> *
> * testcases/kernel/syscalls/clone/clone01.c -> clone, syscalls
> * testcases/kernel/kvm/kvm_pagefault01.c -> kvm
> - * testcases/cve/cve-2017-16939.c -> cve
> */
> static void add_path_groups(struct data_node *groups, const char *fname)
> {
> @@ -1010,6 +1012,35 @@ static void add_path_groups(struct data_node *groups, const char *fname)
> free(buf);
> }
>
> +/*
> + * Add group to specific test tags.
> + */
> +static void add_tag_groups(struct data_node *groups, struct data_node *res)
> +{
> + struct data_node *tags = data_node_hash_get(res, "tags");
> + unsigned int i;
> +
> + if (!tags || tags->type != DATA_ARRAY)
> + return;
> +
> + for (i = 0; i < data_node_array_len(tags); i++) {
> + struct data_node *tag = tags->array.array[i];
> + struct data_node *name;
> +
> + if (tag->type != DATA_ARRAY || !data_node_array_len(tag))
> + continue;
> +
> + name = tag->array.array[0];
> + if (name->type != DATA_STRING)
> + continue;
> +
> + if (!strcmp(name->string.val, "CVE")) {
> + data_node_array_add(groups, data_node_string("cve"));
> + return;
> + }
We may as well add group "regression" if there is a linux-git tag
present.
Otherwise it looks good.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list