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

feat(ecosystems): add support for Mageia ecosystem #3101

Merged
merged 13 commits into from
Feb 11, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions osv/ecosystems/_ecosystems.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .cran import CRAN
from .debian import Debian
from .haskell import Hackage, GHC
from .mageia import Mageia
from .maven import Maven
from .nuget import NuGet
from .packagist import Packagist
Expand Down Expand Up @@ -89,6 +90,7 @@
'Go': 'https://',
'Hackage': 'https://hackage.haskell.org/package/',
'Hex': 'https://hex.pm/packages/',
'Mageia': 'https://madb.mageia.org/show?rpm=',
'npm': 'https://www.npmjs.com/package/',
'NuGet': 'https://www.nuget.org/packages/',
'Packagist': 'https://packagist.org/packages/',
Expand Down Expand Up @@ -120,6 +122,9 @@ def get(name: str) -> Ecosystem:
if name.startswith('AlmaLinux'):
return AlmaLinux()

if name.startswith('Mageia'):
return Mageia()

if name.startswith('Red Hat'):
return RedHat()

Expand Down
3 changes: 2 additions & 1 deletion osv/ecosystems/ecosystems_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class EcosystemsTest(unittest.TestCase):
def setUp(self):
with open('osv/osv-schema/validation/schema.json') as schema_f:
schema = json.load(schema_f)
self.schema_ecosystems = re.compile(schema['$defs']['ecosystem']['pattern'])
self.schema_ecosystems = re.compile(
schema['$defs']['ecosystemWithSuffix']['pattern'])
self.canonical_ecosystems = _ecosystems._ecosystems.keys() # pylint: disable=protected-access

def test_ecosystem_supported_by_schema(self):
Expand Down
40 changes: 40 additions & 0 deletions osv/ecosystems/mageia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Mageia ecosystem helper."""

from ..third_party.univers.rpm import RpmVersion
from .helper_base import Ecosystem


class Mageia(Ecosystem):
andrewpollock marked this conversation as resolved.
Show resolved Hide resolved
"""Mageia ecosystem"""

@property
def name(self):
return 'Mageia'

def sort_key(self, version):
return RpmVersion.from_string(version)

def enumerate_versions(self,
package,
introduced,
fixed=None,
last_affected=None,
limits=None):
raise NotImplementedError('Ecosystem helper does not support enumeration')

@property
def supports_comparing(self):
return True
35 changes: 35 additions & 0 deletions osv/ecosystems/mageia_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Mageia ecosystem helper tests."""

import unittest
from .. import ecosystems


class MageiaEcosystemTest(unittest.TestCase):
"""Mageia ecosystem helper tests."""

def test_mageia(self):
"""Test sort_key"""
ecosystem = ecosystems.get('Mageia')
self.assertEqual('Mageia', ecosystem.name)
self.assertGreater(
ecosystem.sort_key('3.2.7-1.2.mga9'),
ecosystem.sort_key('3.2.7-1.mga9'))
self.assertGreater(
ecosystem.sort_key('3.2.7-1.2.mga9'), ecosystem.sort_key('0'))
andrewpollock marked this conversation as resolved.
Show resolved Hide resolved
self.assertLess(ecosystem.sort_key('invalid'), ecosystem.sort_key('0'))
self.assertGreater(
ecosystem.sort_key('1:1.8.11-1.mga9'),
ecosystem.sort_key('0:1.9.1-2.mga9'))
2 changes: 1 addition & 1 deletion osv/osv-schema
Submodule osv-schema updated 35 files
+16 −0 .editorconfig
+78 −0 .github/workflows/checks.yml
+1 −1 .github/workflows/validate-schema.yml
+1 −0 CHANGELOG.md
+4 −2 README.md
+3 −0 bindings/go/go.mod
+87 −0 bindings/go/osvschema/constants.go
+71 −33 docs/schema.md
+36 −0 ecosystems.json
+144 −0 scripts/update-ecosystems-lists.py
+1 −1 tools/debian/.pylintrc
+1 −1 tools/ghsa/convert_ghsa.py
+103 −0 tools/osv-linter/README.md
+4 −2 tools/osv-linter/internal/checks/checks.go
+1 −1 tools/osv-linter/internal/checks/packages.go
+36 −0 tools/osv-linter/internal/checks/packages_test.go
+3 −3 tools/osv-linter/internal/checks/ranges_test.go
+21 −0 tools/osv-linter/internal/checks/record.go
+51 −0 tools/osv-linter/internal/checks/record_test.go
+18 −4 tools/osv-linter/internal/pkgchecker/ecosystems.go
+42 −0 tools/osv-linter/test_data/MAL-2024-10238.json
+128 −0 tools/osv-linter/test_data/RHSA-2022:0216.json
+1,472 −0 tools/osv-linter/test_data/SUSE-FU-2022:0444-1.json
+19 −2 tools/redhat/README.md
+22 −18 tools/redhat/redhat_osv/convert_redhat_test.py
+11 −4 tools/redhat/redhat_osv/csaf.py
+35 −10 tools/redhat/redhat_osv/osv.py
+7 −1 tools/redhat/redhat_osv/osv_test.py
+2 −2 tools/redhat/testdata/CSAF/rhsa-2003_315.json
+2 −2 tools/redhat/testdata/CSAF/rhsa-2015_0008.json
+2 −2 tools/redhat/testdata/CSAF/rhsa-2024_4546.json
+6,795 −0 tools/redhat/testdata/CSAF/rhsa-2024_6220.json
+19 −139 tools/redhat/testdata/OSV/RHSA-2024_4546.json
+4,616 −0 tools/redhat/testdata/OSV/RHSA-2024_6220.json
+108 −35 validation/schema.json
1 change: 1 addition & 0 deletions source_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
human_link: 'https://advisories.mageia.org/{{ BUG_ID }}.html'
link: 'https://advisories.mageia.org/'
editable: False
strict_validation: True

- name: 'malicious-packages'
versions_from_repo: False
Expand Down
Loading