diff --git a/cloud-init-cve-2023-1786-redact-instance-data-json-main.patch b/cloud-init-cve-2023-1786-redact-instance-data-json-main.patch index f9ffac4..67ea4e7 100644 --- a/cloud-init-cve-2023-1786-redact-instance-data-json-main.patch +++ b/cloud-init-cve-2023-1786-redact-instance-data-json-main.patch @@ -24,9 +24,9 @@ class DataSourceVultr(sources.DataSource): dsname = "Vultr" -+ sensitive_metadata_keys: Tuple[ -+ str, ... -+ ] = sources.DataSource.sensitive_metadata_keys + ("startup-script",) ++ sensitive_metadata_keys: \ ++ Tuple[str, ...] = \ ++ sources.DataSource.sensitive_metadata_keys + ("startup-script",) def __init__(self, sys_cfg, distro, paths): super(DataSourceVultr, self).__init__(sys_cfg, distro, paths) diff --git a/cloud-init-power-rhel-only.patch b/cloud-init-power-rhel-only.patch index fbdc2cf..12e99b0 100644 --- a/cloud-init-power-rhel-only.patch +++ b/cloud-init-power-rhel-only.patch @@ -1,6 +1,14 @@ --- cloudinit/config/cc_refresh_rmc_and_interface.py.orig +++ cloudinit/config/cc_refresh_rmc_and_interface.py -@@ -42,7 +42,7 @@ meta: MetaSchema = { +@@ -15,7 +15,6 @@ from cloudinit import netinfo, subp, uti + from cloudinit.cloud import Cloud + from cloudinit.config import Config + from cloudinit.config.schema import MetaSchema +-from cloudinit.distros import ALL_DISTROS + from cloudinit.settings import PER_ALWAYS + + MODULE_DESCRIPTION = """\ +@@ -42,7 +41,7 @@ meta: MetaSchema = { "name": "Refresh IPv6 Interface and RMC", "title": "Ensure Network Manager is not managing IPv6 interface", "description": MODULE_DESCRIPTION, diff --git a/cloud-init-write-routes.patch b/cloud-init-write-routes.patch index f95cdfa..baf0a7a 100644 --- a/cloud-init-write-routes.patch +++ b/cloud-init-write-routes.patch @@ -18,7 +18,15 @@ if bring_up: --- cloudinit/distros/opensuse.py.orig +++ cloudinit/distros/opensuse.py -@@ -238,6 +238,143 @@ class Distro(distros.Distro): +@@ -15,6 +15,7 @@ from cloudinit import log as logging + from cloudinit import subp, util + from cloudinit.distros import rhel_util as rhutil + from cloudinit.distros.parsers.hostname import HostnameConf ++from cloudinit.net import ipv4_mask_to_net_prefix + from cloudinit.settings import PER_INSTANCE + + LOG = logging.getLogger(__name__) +@@ -238,6 +239,144 @@ class Distro(distros.Distro): conf.set_hostname(hostname) util.write_file(filename, str(conf), 0o644) @@ -72,10 +80,10 @@ + ) + continue + if ( -+ dest == 'default' and -+ has_default_route and -+ gateway == seen_default_gateway -+ ): ++ dest == 'default' ++ and has_default_route ++ and gateway == seen_default_gateway ++ ): + dest_info = dest + if gateway: + dest_info = ' '.join([dest, gateway, '-', '-']) @@ -138,9 +146,10 @@ + for route in device_config.get('routes', []): + config_routes += self._render_route_string(route) + if config_routes: -+ route_file = '/etc/sysconfig/network/ifroute-{}'.format( -+ device_name -+ ) ++ route_file = \ ++ '/etc/sysconfig/network/ifroute-{}'.format( ++ device_name ++ ) + util.write_file(route_file, config_routes) + except Exception: + # the parser above epxects another level of nesting diff --git a/cloud-init.changes b/cloud-init.changes index 2bcf32d..cffc404 100644 --- a/cloud-init.changes +++ b/cloud-init.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Thu Jul 6 12:06:22 UTC 2023 - Robert Schweikert + +- Update cloud-init-write-routes.patch (bsc#1212879) + + Add necessary import statement +- Enable flake8 linting, fix up patches + + cloud-init-cve-2023-1786-redact-instance-data-json-main.patch + + cloud-init-power-rhel-only.patch + + cloud-init-write-routes.patch + + datasourceLocalDisk.patch + ------------------------------------------------------------------- Thu Apr 27 12:22:11 UTC 2023 - Robert Schweikert diff --git a/cloud-init.spec b/cloud-init.spec index de19f56..2f43852 100644 --- a/cloud-init.spec +++ b/cloud-init.spec @@ -54,6 +54,7 @@ BuildRequires: python3-setuptools BuildRequires: python3-Jinja2 BuildRequires: python3-PyYAML BuildRequires: python3-configobj >= 5.0.2 +BuildRequires: python3-flake8 BuildRequires: python3-httpretty BuildRequires: python3-jsonpatch BuildRequires: python3-jsonschema @@ -159,6 +160,7 @@ python3 setup.py build %check make unittest +make flake8 %install python3 setup.py install --root=%{buildroot} --prefix=%{_prefix} --install-lib=%{python3_sitelib} --init-system=%{initsys} diff --git a/datasourceLocalDisk.patch b/datasourceLocalDisk.patch index 815f15f..44ad172 100644 --- a/datasourceLocalDisk.patch +++ b/datasourceLocalDisk.patch @@ -1,6 +1,6 @@ ---- cloudinit/sources/DataSourceLocalDisk.py 2016/11/25 19:01:00 1.1 -+++ cloudinit/sources/DataSourceLocalDisk.py 2016/11/26 20:42:02 -@@ -0,0 +1,101 @@ +--- /dev/null ++++ cloudinit/sources/DataSourceLocalDisk.py +@@ -0,0 +1,107 @@ +# vi: ts=4 expandtab +# +# Copyright (C) 2016 SUSE Linux GmbH @@ -51,17 +51,22 @@ + + # Check to see if the seed dir has data. + try: -+ seeded = util.pathprefix2dict(self.seed_dir, ['user-data','meta-data'],['vendor-data']) ++ seeded = util.pathprefix2dict( ++ self.seed_dir, ['user-data', 'meta-data'], ['vendor-data'] ++ ) + found.append(self.seed_dir) + mydata = _merge_new_seed(mydata, seeded) -+ except ValueError as e: ++ except ValueError: + pass + + try: -+ seeded = util.pathprefix2dict('/cloud-init-config', ['user-data','meta-data'],['vendor-data']) ++ seeded = util.pathprefix2dict( ++ '/cloud-init-config', ['user-data', 'meta-data'], ++ ['vendor-data'] ++ ) + found.append('/cloud-init-config') + mydata = _merge_new_seed(mydata, seeded) -+ except ValueError as e: ++ except ValueError: + return False + + # Merge in the defaults @@ -78,6 +83,7 @@ + # quickly (local check only) if self.instance_id is still valid + return sources.instance_id_matches_system_uuid(self.get_instance_id()) + ++ +def _merge_new_seed(cur, seeded): + ret = cur.copy() +