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

Add validation for <memory> #406

Merged
merged 3 commits into from Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -342,6 +342,12 @@ AsValidatorIssueTag as_validator_issue_tag_list[] = {
N_("This `hardware` item contains an invalid value. It should be a Computer Hardware ID (CHID) UUID without braces.")
},

{ "relation-memory-value-invalid",
AS_ISSUE_SEVERITY_WARNING,
/* TRANSLATORS: Please do not translate AppStream tag and property names (in backticks). */
N_("A `memory` item must only contain a non-zero integer value, depicting a system memory size in mebibyte (MiB)")
},

{ "component-type-invalid",
AS_ISSUE_SEVERITY_ERROR,
N_("The set component type is not a recognized, valid AppStream component type.")
@@ -1473,6 +1473,11 @@ as_validator_check_relations (AsValidator *validator,
as_validator_add_issue (validator, iter, "relation-hardware-value-invalid", content);
}

/* check memory for sanity */
if (item_kind == AS_RELATION_ITEM_KIND_MEMORY)
if (!as_str_verify_integer (content, 1, G_MAXINT64))
as_validator_add_issue (validator, iter, "relation-memory-value-invalid", content);

/* check for redefinition */
rel_item_id = g_strdup_printf ("%s%s%s%s", node_name, content, compare_str, version);
rel_dupe_type = g_hash_table_lookup (known_entries, rel_item_id);