Commit Graph

11 Commits

Author SHA1 Message Date
Debarshi Ray
596ef2fd7a appdata: Fix a -Wanalyzer-null-argument warning
OpenScanHub [1] triggered this and flagged it as CWE-688 [2]:
  common/flatpak-appdata.c:298:7: warning[-Wanalyzer-null-argument]: use
      of NULL ‘parent’ where non-null expected
  common/flatpak-appdata.c:282:6: branch_false: following ‘false’
      branch...
  common/flatpak-appdata.c:285:3: branch_false: ...to here
  common/flatpak-appdata.c:285:3: branch_true: following ‘true’
      branch...
  common/flatpak-appdata.c:287:15: branch_true: ...to here
  common/flatpak-appdata.c:289:6: branch_false: following ‘false’
      branch...
  common/flatpak-appdata.c:297:7: branch_false: ...to here
  common/flatpak-appdata.c:297:6: branch_true: following ‘true’ branch
      (when the strings are equal)...
  common/flatpak-appdata.c:298:7: branch_true: ...to here
  common/flatpak-appdata.c:298:7: danger: argument 1 (‘parent’) NULL
      where non-null expected
  #  296|     /* avoid picking up <id> elements from e.g. <provides> */
  #  297|     if (g_str_equal (element_name, "id") &&
  #  298|->       g_str_equal (parent, "component"))
  #  299|       {
  #  300|         component->id = g_steal_pointer (&text);

The parsing code doesn't throw any errors from G_MARKUP_ERROR.  It
expects the input to be valid, and relies on assertions to express that.
eg., it asserts that a <component> element or tag is encountered before
any other, and particularly <content_attribute>, <content_rating> and
<release>.

In the same vein, an assertion was added to express that an <id> element
or tag always has a parent.

Spotted by Siteshwar Vashisht.

[1] https://openscanhub.dev/

[2] https://cwe.mitre.org/data/definitions/688.html
2026-03-11 22:31:49 +00:00
Chris Williams
73d4a3b062 appdata: exclude <name> element inside <developer>
<developer_name> has been deprecated in favor of <developer> with a
<name> child. We need to ensure that this developer name isn't parsed
as the application name.

Fixes: #5700
2024-03-12 08:31:08 -05:00
Phaedrus Leeds
600e18567c Add a vim modeline and .editorconfig
To make indentation work with less effort. The modeline was copied from
libostree with minor modification and the .editorconfig from GLib.

The advantage of having both a modeline and an editorconfig is we can
work out of the box on more editor setups, and the modeline allows us to
specify the style with a lot more fine grained control.
2022-08-22 19:48:10 -07:00
Alexander Larsson
7c3e6f7214 appdata: Fix leak of id string. 2019-12-19 16:52:58 +01:00
Philip Withnall
0e53094645 flatpak-appdata: Add support for extracting app content ratings
This will be used in upcoming commits to enforce parental controls on
app installations.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://github.com/flatpak/flatpak/pull/2797
2019-10-03 10:42:04 +02:00
Matthew Leeds
8d962a686f Run uncrustify
I had to make a few manual edits but other than those the changes look
reasonable.

Closes: #2715
Approved by: matthiasclasen
2019-02-25 18:12:30 +00:00
Matthias Clasen
228ee0bd0a appdata: Ignore allowed attributes
We only interested in a few of the attributes of some
tags, but we shouldn't fail if other valid attributes
are present.

Add some of the allowed attributes to the <release> element
in the appdata test and verify that we can still parse it.

The appstream spec is here:
https://www.freedesktop.org/software/appstream/docs/

Closes: #2674
Approved by: matthiasclasen
2019-02-02 00:52:32 +00:00
Alexander Larsson
f0c404d104 Add backported version of g_date_time_new_from_iso8601
Closes: #2642
Approved by: matthiasclasen
2019-01-28 16:36:38 +00:00
Matthias Clasen
69212da002 Parse date attributes in appdata
The spec allowed either timestamp or date to
be specified for a release, so we should support
both.

Closes: #2614

Closes: #2619
Approved by: alexlarsson
2019-01-21 08:46:57 +00:00
Matthias Clasen
5db64fe342 Add a minimal GMarkup-based appdata parser
This parser nderstands just enough appdata to pull
out the strings we want.

Closes: #2580
Approved by: alexlarsson
2019-01-14 15:06:41 +00:00
Matthias Clasen
728f917418 Move appdata parsing to its own file
This is just moving some code around for now.
It is still using libappstream-glib.

Closes: #2580
Approved by: alexlarsson
2019-01-14 15:06:41 +00:00