From f4ed32e69d34576bd45a0b96cf914c377c96b5d6 Mon Sep 17 00:00:00 2001 From: Inessa Vasilevskaya Date: Wed, 13 Jan 2021 15:55:08 +0100 Subject: [PATCH] Introduced a JSON schema of a leapp report MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generated by https://jsonschema.net and adjusted manually. The patch contains 2 schema files: - 1.0.0 that matches the version that foreman_leapp relies on - 1.1.0 that has the stable report key. Basic unit test coverage is presented in test_reporting.py - the sample leapp-report.json from vagrant box is checked against json schema v 1.0.0 and 1.1.0. OAMG-4263 Co-Authored-By: Petr Stodůlka --- packaging/leapp.spec | 6 + report-schema-v100.json | 648 +++++++++++++++++ report-schema-v110.json | 664 ++++++++++++++++++ requirements-tests.txt | 2 + .../leapp-report-stable-key.json | 590 ++++++++++++++++ .../schemas/report-schema-v100.json | 1 + .../schemas/report-schema-v110.json | 1 + tests/scripts/test_reporting.py | 22 + 8 files changed, 1934 insertions(+) create mode 100644 report-schema-v100.json create mode 100644 report-schema-v110.json create mode 100644 tests/data/report-schema/leapp-report-stable-key.json create mode 120000 tests/data/report-schema/schemas/report-schema-v100.json create mode 120000 tests/data/report-schema/schemas/report-schema-v110.json diff --git a/packaging/leapp.spec b/packaging/leapp.spec index 2d9d5b6b1..03058dd88 100644 --- a/packaging/leapp.spec +++ b/packaging/leapp.spec @@ -191,6 +191,9 @@ install -m 0755 -d %{buildroot}%{_mandir}/man1 install -m 0644 -p man/snactor.1 %{buildroot}%{_mandir}/man1/ %if !0%{?fedora} +install -m 0755 -d %{buildroot}%{_datadir}/leapp +install -m 0755 -d %{buildroot}%{_datadir}/leapp/report_schema +install -m 0644 -p report-schema-v110.json %{buildroot}%{_datadir}/leapp/report_schema/report-schema.json install -m 0755 -d %{buildroot}%{_sharedstatedir}/leapp install -m 0755 -d %{buildroot}%{_sysconfdir}/leapp install -m 0755 -d %{buildroot}%{_sysconfdir}/leapp/repos.d @@ -234,6 +237,9 @@ rm -f %{buildroot}/%{_bindir}/leapp %{_bindir}/leapp %dir %{_sharedstatedir}/leapp %dir %{_localstatedir}/log/leapp +%dir %{_datadir}/leapp/ +%dir %{_datadir}/leapp/report_schema/ +%{_datadir}/leapp/report_schema %{python2_sitelib}/leapp/cli %endif diff --git a/report-schema-v100.json b/report-schema-v100.json new file mode 100644 index 000000000..144587e76 --- /dev/null +++ b/report-schema-v100.json @@ -0,0 +1,648 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "$id": "http://example.com/example.json", + "type": "object", + "title": "The (pre)upgrade report schema", + "description": "The root schema comprises the entire JSON document.", + "default": {}, + "version": "1.0.0", + "examples": [ + { + "leapp_run_id": "a91dccab-84e8-4a28-b28e-102b073200a9", + "entries": [ + { + "hostname": "vagrant-leapp-20210113121507", + "severity": "info", + "tags": [ + "repository" + ], + "timeStamp": "2021-01-13T13:04:06.895402Z", + "title": "Excluded RHEL 8 repositories", + "detail": { + "external": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ] + }, + "actor": "repositories_blacklist", + "summary": "The following repositories are not supported by Red Hat and are excluded from the list of repositories used during the upgrade.\n- codeready-builder-for-rhel-8-x86_64-rpms", + "audience": "sysadmin", + "flags": [ + "failure" + ], + "id": "88e518df66f34e0097ef7b4a4121f50eb5bcf9e8b2c017d1d07dca5e22db65e5" + }, + { + "hostname": "vagrant-leapp-20210113121507", + "severity": "high", + "title": "Packages not signed by Red Hat found on the system", + "timeStamp": "2021-01-13T13:04:20.582335Z", + "tags": [ + "sanity" + ], + "actor": "red_hat_signed_rpm_check", + "summary": "The following packages have not been signed by Red Hat and may be removed during the upgrade process in case Red Hat-signed packages to be removed during the upgrade depend on them:\n- cockpit-leapp\n- leapp\n- leapp-deps\n- leapp-repository\n- leapp-repository-deps\n- python2-leapp\n- snactor", + "audience": "sysadmin", + "id": "181fd075531341d88f5bdd9c17a379faa483fe188f2d0bfc125c66de3fd9c03f" + }, + { + "hostname": "vagrant-leapp-20210113121507", + "severity": "low", + "title": "Grep has incompatible changes in the next major version", + "timeStamp": "2021-01-13T13:04:21.087993Z", + "tags": [ + "tools" + ], + "detail": { + "related_resources": [ + { + "scheme": "package", + "title": "grep" + } + ], + "remediations": [ + { + "type": "hint", + "context": "Please update your scripts to be compatible with the changes." + } + ], + "external": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ] + }, + "actor": "checkgrep", + "summary": "If a file contains data improperly encoded for the current locale, and this is discovered before any of the file's contents are output, grep now treats the file as binary.\nThe 'grep -P' no longer reports an error and exits when given invalid UTF-8 data. Instead, it considers the data to be non-matching.\nIn locales with multibyte character encodings other than UTF-8, grep -P now reports an error and exits instead of misbehaving.\nWhen searching binary data, grep now may treat non-text bytes as line terminators. This can boost performance significantly.\nThe 'grep -z' no longer automatically treats the byte '\\200' as binary data.\nContext no longer excludes selected lines omitted because of -m. For example, 'grep \"^\" -m1 -A1' now outputs the first two input lines, not just the first line.\n", + "audience": "sysadmin", + "id": "d8f145577982de8387eb7a6427320065182e32f68cd09a5c768c5f3359a6734e" + } + ] + } + ], + "required": [ + "leapp_run_id", + "entries" + ], + "properties": { + "leapp_run_id": { + "$id": "#/properties/leapp_run_id", + "type": "string", + "title": "The leapp_run_id schema", + "description": "Unique id of a leapp execution.", + "default": "", + "examples": [ + "a91dccab-84e8-4a28-b28e-102b073200a9" + ] + }, + "entries": { + "$id": "#/properties/entries", + "type": "array", + "title": "The report entries schema", + "description": "A list of all report entries that comprise a report", + "default": [], + "examples": [ + [ + { + "hostname": "vagrant-leapp-20210113121507", + "severity": "info", + "tags": [ + "repository" + ], + "timeStamp": "2021-01-13T13:04:06.895402Z", + "title": "Excluded RHEL 8 repositories", + "detail": { + "external": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ] + }, + "actor": "repositories_blacklist", + "summary": "The following repositories are not supported by Red Hat and are excluded from the list of repositories used during the upgrade.\n- codeready-builder-for-rhel-8-x86_64-rpms", + "audience": "sysadmin", + "flags": [ + "failure" + ], + "id": "88e518df66f34e0097ef7b4a4121f50eb5bcf9e8b2c017d1d07dca5e22db65e5" + }, + { + "hostname": "vagrant-leapp-20210113121507", + "severity": "high", + "title": "Packages not signed by Red Hat found on the system", + "timeStamp": "2021-01-13T13:04:20.582335Z", + "tags": [ + "sanity" + ], + "actor": "red_hat_signed_rpm_check", + "summary": "The following packages have not been signed by Red Hat and may be removed during the upgrade process in case Red Hat-signed packages to be removed during the upgrade depend on them:\n- cockpit-leapp\n- leapp\n- leapp-deps\n- leapp-repository\n- leapp-repository-deps\n- python2-leapp\n- snactor", + "audience": "sysadmin", + "id": "181fd075531341d88f5bdd9c17a379faa483fe188f2d0bfc125c66de3fd9c03f" + } + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/entries/items", + "anyOf": [ + { + "$id": "#/properties/entries/items/anyOf/0", + "type": "object", + "title": "The first anyOf schema", + "description": "A report entry.", + "default": {}, + "examples": [ + { + "hostname": "vagrant-leapp-20210113121507", + "severity": "info", + "tags": [ + "repository" + ], + "timeStamp": "2021-01-13T13:04:06.895402Z", + "title": "Excluded RHEL 8 repositories", + "detail": { + "external": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ] + }, + "actor": "repositories_blacklist", + "summary": "The following repositories are not supported by Red Hat and are excluded from the list of repositories used during the upgrade.\n- codeready-builder-for-rhel-8-x86_64-rpms", + "audience": "sysadmin", + "flags": [ + "failure" + ], + "id": "88e518df66f34e0097ef7b4a4121f50eb5bcf9e8b2c017d1d07dca5e22db65e5" + } + ], + "required": [ + "hostname", + "severity", + "timeStamp", + "title", + "actor", + "summary", + "audience", + "id" + ], + "properties": { + "hostname": { + "$id": "#/properties/entries/items/anyOf/0/properties/hostname", + "type": "string", + "title": "The hostname schema", + "description": "A hostname specified in a report entry.", + "default": "", + "examples": [ + "vagrant-leapp-20210113121507" + ] + }, + "severity": { + "$id": "#/properties/entries/items/anyOf/0/properties/severity", + "type": "string", + "title": "The severity schema", + "description": "Report severity.", + "default": "info", + "enum": ["info", "low", "medium", "high"], + "examples": [ + "info" + ] + }, + "tags": { + "$id": "#/properties/entries/items/anyOf/0/properties/tags", + "type": "array", + "title": "The tags schema", + "description": "Tags used for the report. May be merged with flags in the next version.", + "default": [], + "examples": [ + [ + "repository" + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/entries/items/anyOf/0/properties/tags/items", + "anyOf": [ + { + "$id": "#/properties/entries/items/anyOf/0/properties/tags/items/anyOf/0", + "type": "string", + "title": "The first anyOf schema", + "description": "A report tag.", + "default": "", + "examples": [ + "repository" + ] + } + ] + } + }, + "timeStamp": { + "$id": "#/properties/entries/items/anyOf/0/properties/timeStamp", + "type": "string", + "title": "The timeStamp schema", + "description": "Report entry timestamp.", + "default": "", + "examples": [ + "2021-01-13T13:04:06.895402Z" + ] + }, + "title": { + "$id": "#/properties/entries/items/anyOf/0/properties/title", + "type": "string", + "title": "The title schema", + "description": "Report title.", + "default": "", + "examples": [ + "Excluded RHEL 8 repositories" + ] + }, + "detail": { + "$id": "#/properties/entries/items/anyOf/0/properties/detail", + "type": "object", + "title": "The detail schema", + "description": "Additional information connected to the report (remediations, external links, related resources).", + "default": {}, + "examples": [ + { + "external": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ] + } + ], + "anyOf": [ + { "required": [ "external" ] }, + { "required": [ "remediations" ] }, + { "required": [ "related_resources" ] } + ], + "properties": { + "external": { + "$id": "#/properties/entries/items/anyOf/0/properties/detail/properties/external", + "type": "array", + "title": "The external links schema", + "description": "List of external links mentioned in the report entry.", + "default": [], + "examples": [ + [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/entries/items/anyOf/0/properties/detail/properties/external/items", + "anyOf": [ + { + "$id": "#/properties/entries/items/anyOf/0/properties/detail/properties/external/items/anyOf/0", + "type": "object", + "title": "The first external link", + "description": "An external link.", + "default": {}, + "examples": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ], + "required": [ + "url", + "title" + ], + "properties": { + "url": { + "$id": "#/properties/entries/items/anyOf/0/properties/detail/properties/external/items/anyOf/0/properties/url", + "type": "string", + "title": "The url schema", + "description": "An external link url.", + "default": "", + "examples": [ + "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository." + ] + }, + "title": { + "$id": "#/properties/entries/items/anyOf/0/properties/detail/properties/external/items/anyOf/0/properties/title", + "type": "string", + "title": "The title schema", + "description": "An external link title.", + "default": "", + "examples": [ + "CodeReady Linux Builder repository" + ] + } + }, + "additionalProperties": true + } + ] + } + }, + "related_resources": { + "$id": "#/properties/detail/properties/related_resources", + "type": "array", + "title": "The related_resources schema", + "description": "A list of related resources.", + "default": [], + "examples": [ + [ + { + "scheme": "package", + "title": "grep" + } + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/detail/properties/related_resources/items", + "anyOf": [ + { + "$id": "#/properties/detail/properties/related_resources/items/anyOf/0", + "type": "object", + "title": "The first related resource", + "description": "A resource related to the report entry.", + "default": {}, + "examples": [ + { + "scheme": "package", + "title": "grep" + } + ], + "required": [ + "scheme", + "title" + ], + "properties": { + "scheme": { + "$id": "#/properties/detail/properties/related_resources/items/anyOf/0/properties/scheme", + "type": "string", + "title": "The scheme schema", + "description": "A scheme (type) of the related resource.", + "default": "", + "examples": [ + "package" + ] + }, + "title": { + "$id": "#/properties/detail/properties/related_resources/items/anyOf/0/properties/title", + "type": "string", + "title": "The title schema", + "description": "Title of the related resource.", + "default": "", + "examples": [ + "grep" + ] + } + }, + "additionalProperties": true + } + ] + } + }, + "remediations": { + "$id": "#/properties/detail/properties/remediations", + "type": "array", + "title": "The remediations schema", + "description": "A list of remediations, describes what needs to be done to fix the problem.", + "default": [], + "examples": [ + [ + { + "type": "hint", + "context": "Please update your scripts to be compatible with the changes." + } + ], + [ + { + "type": "hint", + "context": "This is remediation with hint and the command." + }, + { + "type": "command", + "context": [ "echo", "some text" ] + } + ], + [ + { + "type": "command", + "context": [ "echo", "some text", "2" ] + }, + { + "type": "command", + "context": [ "echo", "2nd", "cmd" ] + } + ], + [ + { + "type": "hint", + "context": "The remediation with hint, command, and playbook." + }, + { + "type": "command", + "context": [ "echo", "some text" ] + }, + { + "type": "playbook", + "context": "/path/to/playbook" + } + ], + [ + { + "type": "playbook", + "context": "/path/to/playbook" + } + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/detail/properties/remediations/items", + "anyOf": [ + { + "$id": "#/properties/detail/properties/remediations/items/anyOf/0", + "type": "object", + "title": "The first remediation", + "description": "", + "default": {}, + "examples": [ + { + "type": "hint", + "context": "Please update your scripts to be compatible with the changes." + } + ], + "required": [ + "type", + "context" + ], + "properties": { + "type": { + "$id": "#/properties/detail/properties/remediations/items/anyOf/0/properties/type", + "type": "string", + "title": "The type schema", + "description": "Type of remediation.", + "default": "", + "enum": ["hint", "playbook"], + "examples": [ + "hint" + ] + }, + "context": { + "$id": "#/properties/detail/properties/remediations/items/anyOf/0/properties/context", + "type": "string", + "title": "The context schema", + "description": "The remediation itself.", + "default": "", + "examples": [ + "Please update your scripts to be compatible with the changes." + ] + } + }, + "additionalProperties": true + }, + { + "$id": "#/properties/detail/properties/remediations/items/anyOf/1", + "type": "object", + "title": "The first remediation", + "description": "", + "default": {}, + "examples": [ + { + "type": "command", + "context": [ "rm -rf /tmp/42" ] + } + ], + "required": [ + "type", + "context" + ], + "properties": { + "type": { + "$id": "#/properties/detail/properties/remediations/items/anyOf/1/properties/type", + "type": "string", + "title": "The type schema", + "description": "Type of remediation.", + "default": "", + "enum": ["command"], + "examples": ["command"] + }, + "context": { + "$id": "#/properties/detail/properties/remediations/items/anyOf/1/properties/context", + "type": "array", + "title": "The context schema", + "description": "List of remediation commands.", + "default": [], + "examples": [ + [ + "rm -rf /tmp/42" + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/detail/properties/remediations/items/anyOf/1/properties/context/items", + "anyOf": [ + { + "$id": "#/properties/detail/properties/remediations/items/anyOf/1/properties/context/items/anyOf/0", + "type": "string", + "title": "The remediation command schema", + "description": "The remediation in form of a command.", + "default": "", + "examples": [ + "rm -rf /tmp/42" + ] + } + ] + } + } + }, + "additionalProperties": true + } + ] + } + } + }, + "additionalProperties": true + }, + "actor": { + "$id": "#/properties/entries/items/anyOf/0/properties/actor", + "type": "string", + "title": "The actor name schema", + "description": "Name of the actor that reported a problem.", + "default": "", + "examples": [ + "repositories_blacklist" + ] + }, + "summary": { + "$id": "#/properties/entries/items/anyOf/0/properties/summary", + "type": "string", + "title": "The summary schema", + "description": "Details of the reported problem.", + "default": "", + "examples": [ + "The following repositories are not supported by Red Hat and are excluded from the list of repositories used during the upgrade.\n- codeready-builder-for-rhel-8-x86_64-rpms" + ] + }, + "audience": { + "$id": "#/properties/entries/items/anyOf/0/properties/audience", + "type": "string", + "title": "The audience schema", + "description": "The key audience of the reported problem.", + "default": "", + "enum": ["sysadmin", "developer"], + "examples": [ + "sysadmin" + ] + }, + "flags": { + "$id": "#/properties/entries/items/anyOf/0/properties/flags", + "type": "array", + "title": "Report flags schema", + "description": "List of flags, a flag is a predefined string", + "default": [], + "examples": [ + [ + "failure" + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/entries/items/anyOf/0/properties/flags/items", + "anyOf": [ + { + "$id": "#/properties/entries/items/anyOf/0/properties/flags/items/anyOf/0", + "type": "string", + "title": "The report flag schema", + "description": "A report flag can have a predefined value.", + "default": "", + "enum": ["failure", "inhibitor"], + "examples": [ + "failure" + ] + } + ] + } + }, + "id": { + "$id": "#/properties/entries/items/anyOf/0/properties/id", + "type": "string", + "title": "The id schema", + "description": "Unique id for the report entry. Not stable.", + "default": "", + "examples": [ + "88e518df66f34e0097ef7b4a4121f50eb5bcf9e8b2c017d1d07dca5e22db65e5" + ] + } + }, + "additionalProperties": true + } + ] + } + } + }, + "additionalProperties": true +} diff --git a/report-schema-v110.json b/report-schema-v110.json new file mode 100644 index 000000000..706008345 --- /dev/null +++ b/report-schema-v110.json @@ -0,0 +1,664 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "$id": "http://example.com/example.json", + "type": "object", + "title": "The (pre)upgrade report schema", + "description": "The root schema comprises the entire JSON document.", + "default": {}, + "version": "1.0.0", + "examples": [ + { + "leapp_run_id": "a91dccab-84e8-4a28-b28e-102b073200a9", + "entries": [ + { + "hostname": "vagrant-leapp-20210113121507", + "severity": "info", + "tags": [ + "repository" + ], + "timeStamp": "2021-01-13T13:04:06.895402Z", + "title": "Excluded RHEL 8 repositories", + "detail": { + "external": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ] + }, + "actor": "repositories_blacklist", + "summary": "The following repositories are not supported by Red Hat and are excluded from the list of repositories used during the upgrade.\n- codeready-builder-for-rhel-8-x86_64-rpms", + "audience": "sysadmin", + "flags": [ + "failure" + ], + "key": "a12013a95a6d305adc9f4f675186f89760af1a7e", + "id": "88e518df66f34e0097ef7b4a4121f50eb5bcf9e8b2c017d1d07dca5e22db65e5" + }, + { + "hostname": "vagrant-leapp-20210113121507", + "severity": "high", + "title": "Packages not signed by Red Hat found on the system", + "timeStamp": "2021-01-13T13:04:20.582335Z", + "tags": [ + "sanity" + ], + "actor": "red_hat_signed_rpm_check", + "summary": "The following packages have not been signed by Red Hat and may be removed during the upgrade process in case Red Hat-signed packages to be removed during the upgrade depend on them:\n- cockpit-leapp\n- leapp\n- leapp-deps\n- leapp-repository\n- leapp-repository-deps\n- python2-leapp\n- snactor", + "audience": "sysadmin", + "key": "13f0791ae5f19f50e7d0d606fb6501f91b1efb2c", + "id": "181fd075531341d88f5bdd9c17a379faa483fe188f2d0bfc125c66de3fd9c03f" + }, + { + "hostname": "vagrant-leapp-20210113121507", + "severity": "low", + "title": "Grep has incompatible changes in the next major version", + "timeStamp": "2021-01-13T13:04:21.087993Z", + "tags": [ + "tools" + ], + "detail": { + "related_resources": [ + { + "scheme": "package", + "title": "grep" + } + ], + "remediations": [ + { + "type": "hint", + "context": "Please update your scripts to be compatible with the changes." + } + ], + "external": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ] + }, + "actor": "checkgrep", + "summary": "If a file contains data improperly encoded for the current locale, and this is discovered before any of the file's contents are output, grep now treats the file as binary.\nThe 'grep -P' no longer reports an error and exits when given invalid UTF-8 data. Instead, it considers the data to be non-matching.\nIn locales with multibyte character encodings other than UTF-8, grep -P now reports an error and exits instead of misbehaving.\nWhen searching binary data, grep now may treat non-text bytes as line terminators. This can boost performance significantly.\nThe 'grep -z' no longer automatically treats the byte '\\200' as binary data.\nContext no longer excludes selected lines omitted because of -m. For example, 'grep \"^\" -m1 -A1' now outputs the first two input lines, not just the first line.\n", + "audience": "sysadmin", + "key": "94665a499e2eeee35eca3e7093a7abe183384b16", + "id": "d8f145577982de8387eb7a6427320065182e32f68cd09a5c768c5f3359a6734e" + } + ] + } + ], + "required": [ + "leapp_run_id", + "entries" + ], + "properties": { + "leapp_run_id": { + "$id": "#/properties/leapp_run_id", + "type": "string", + "title": "The leapp_run_id schema", + "description": "Unique id of a leapp execution.", + "default": "", + "examples": [ + "a91dccab-84e8-4a28-b28e-102b073200a9" + ] + }, + "entries": { + "$id": "#/properties/entries", + "type": "array", + "title": "The report entries schema", + "description": "A list of all report entries that comprise a report", + "default": [], + "examples": [ + [ + { + "hostname": "vagrant-leapp-20210113121507", + "severity": "info", + "tags": [ + "repository" + ], + "timeStamp": "2021-01-13T13:04:06.895402Z", + "title": "Excluded RHEL 8 repositories", + "detail": { + "external": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ] + }, + "actor": "repositories_blacklist", + "summary": "The following repositories are not supported by Red Hat and are excluded from the list of repositories used during the upgrade.\n- codeready-builder-for-rhel-8-x86_64-rpms", + "audience": "sysadmin", + "flags": [ + "failure" + ], + "key": "a12013a95a6d305adc9f4f675186f89760af1a7e", + "id": "88e518df66f34e0097ef7b4a4121f50eb5bcf9e8b2c017d1d07dca5e22db65e5" + }, + { + "hostname": "vagrant-leapp-20210113121507", + "severity": "high", + "title": "Packages not signed by Red Hat found on the system", + "timeStamp": "2021-01-13T13:04:20.582335Z", + "tags": [ + "sanity" + ], + "actor": "red_hat_signed_rpm_check", + "summary": "The following packages have not been signed by Red Hat and may be removed during the upgrade process in case Red Hat-signed packages to be removed during the upgrade depend on them:\n- cockpit-leapp\n- leapp\n- leapp-deps\n- leapp-repository\n- leapp-repository-deps\n- python2-leapp\n- snactor", + "audience": "sysadmin", + "key": "13f0791ae5f19f50e7d0d606fb6501f91b1efb2c", + "id": "181fd075531341d88f5bdd9c17a379faa483fe188f2d0bfc125c66de3fd9c03f" + } + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/entries/items", + "anyOf": [ + { + "$id": "#/properties/entries/items/anyOf/0", + "type": "object", + "title": "The first anyOf schema", + "description": "A report entry.", + "default": {}, + "examples": [ + { + "hostname": "vagrant-leapp-20210113121507", + "severity": "info", + "tags": [ + "repository" + ], + "timeStamp": "2021-01-13T13:04:06.895402Z", + "title": "Excluded RHEL 8 repositories", + "detail": { + "external": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ] + }, + "actor": "repositories_blacklist", + "summary": "The following repositories are not supported by Red Hat and are excluded from the list of repositories used during the upgrade.\n- codeready-builder-for-rhel-8-x86_64-rpms", + "audience": "sysadmin", + "flags": [ + "failure" + ], + "key": "a12013a95a6d305adc9f4f675186f89760af1a7e", + "id": "88e518df66f34e0097ef7b4a4121f50eb5bcf9e8b2c017d1d07dca5e22db65e5" + } + ], + "required": [ + "hostname", + "severity", + "timeStamp", + "title", + "actor", + "summary", + "audience", + "id" + ], + "properties": { + "hostname": { + "$id": "#/properties/entries/items/anyOf/0/properties/hostname", + "type": "string", + "title": "The hostname schema", + "description": "A hostname specified in a report entry.", + "default": "", + "examples": [ + "vagrant-leapp-20210113121507" + ] + }, + "severity": { + "$id": "#/properties/entries/items/anyOf/0/properties/severity", + "type": "string", + "title": "The severity schema", + "description": "Report severity.", + "default": "info", + "enum": ["info", "low", "medium", "high"], + "examples": [ + "info" + ] + }, + "tags": { + "$id": "#/properties/entries/items/anyOf/0/properties/tags", + "type": "array", + "title": "The tags schema", + "description": "Tags used for the report. May be merged with flags in the next version.", + "default": [], + "examples": [ + [ + "repository" + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/entries/items/anyOf/0/properties/tags/items", + "anyOf": [ + { + "$id": "#/properties/entries/items/anyOf/0/properties/tags/items/anyOf/0", + "type": "string", + "title": "The first anyOf schema", + "description": "A report tag.", + "default": "", + "examples": [ + "repository" + ] + } + ] + } + }, + "timeStamp": { + "$id": "#/properties/entries/items/anyOf/0/properties/timeStamp", + "type": "string", + "title": "The timeStamp schema", + "description": "Report entry timestamp.", + "default": "", + "examples": [ + "2021-01-13T13:04:06.895402Z" + ] + }, + "title": { + "$id": "#/properties/entries/items/anyOf/0/properties/title", + "type": "string", + "title": "The title schema", + "description": "Report title.", + "default": "", + "examples": [ + "Excluded RHEL 8 repositories" + ] + }, + "detail": { + "$id": "#/properties/entries/items/anyOf/0/properties/detail", + "type": "object", + "title": "The detail schema", + "description": "Additional information connected to the report (remediations, external links, related resources).", + "default": {}, + "examples": [ + { + "external": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ] + } + ], + "anyOf": [ + { "required": [ "external" ] }, + { "required": [ "remediations" ] }, + { "required": [ "related_resources" ] } + ], + "properties": { + "external": { + "$id": "#/properties/entries/items/anyOf/0/properties/detail/properties/external", + "type": "array", + "title": "The external links schema", + "description": "List of external links mentioned in the report entry.", + "default": [], + "examples": [ + [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/entries/items/anyOf/0/properties/detail/properties/external/items", + "anyOf": [ + { + "$id": "#/properties/entries/items/anyOf/0/properties/detail/properties/external/items/anyOf/0", + "type": "object", + "title": "The first external link", + "description": "An external link.", + "default": {}, + "examples": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository.", + "title": "CodeReady Linux Builder repository" + } + ], + "required": [ + "url", + "title" + ], + "properties": { + "url": { + "$id": "#/properties/entries/items/anyOf/0/properties/detail/properties/external/items/anyOf/0/properties/url", + "type": "string", + "title": "The url schema", + "description": "An external link url.", + "default": "", + "examples": [ + "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/package_manifest/codereadylinuxbuilder-repository." + ] + }, + "title": { + "$id": "#/properties/entries/items/anyOf/0/properties/detail/properties/external/items/anyOf/0/properties/title", + "type": "string", + "title": "The title schema", + "description": "An external link title.", + "default": "", + "examples": [ + "CodeReady Linux Builder repository" + ] + } + }, + "additionalProperties": true + } + ] + } + }, + "related_resources": { + "$id": "#/properties/detail/properties/related_resources", + "type": "array", + "title": "The related_resources schema", + "description": "A list of related resources.", + "default": [], + "examples": [ + [ + { + "scheme": "package", + "title": "grep" + } + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/detail/properties/related_resources/items", + "anyOf": [ + { + "$id": "#/properties/detail/properties/related_resources/items/anyOf/0", + "type": "object", + "title": "The first related resource", + "description": "A resource related to the report entry.", + "default": {}, + "examples": [ + { + "scheme": "package", + "title": "grep" + } + ], + "required": [ + "scheme", + "title" + ], + "properties": { + "scheme": { + "$id": "#/properties/detail/properties/related_resources/items/anyOf/0/properties/scheme", + "type": "string", + "title": "The scheme schema", + "description": "A scheme (type) of the related resource.", + "default": "", + "examples": [ + "package" + ] + }, + "title": { + "$id": "#/properties/detail/properties/related_resources/items/anyOf/0/properties/title", + "type": "string", + "title": "The title schema", + "description": "Title of the related resource.", + "default": "", + "examples": [ + "grep" + ] + } + }, + "additionalProperties": true + } + ] + } + }, + "remediations": { + "$id": "#/properties/detail/properties/remediations", + "type": "array", + "title": "The remediations schema", + "description": "A list of remediations, describes what needs to be done to fix the problem.", + "default": [], + "examples": [ + [ + { + "type": "hint", + "context": "Please update your scripts to be compatible with the changes." + } + ], + [ + { + "type": "hint", + "context": "This is remediation with hint and the command." + }, + { + "type": "command", + "context": [ "echo", "some text" ] + } + ], + [ + { + "type": "command", + "context": [ "echo", "some text", "2" ] + }, + { + "type": "command", + "context": [ "echo", "2nd", "cmd" ] + } + ], + [ + { + "type": "hint", + "context": "The remediation with hint, command, and playbook." + }, + { + "type": "command", + "context": [ "echo", "some text" ] + }, + { + "type": "playbook", + "context": "/path/to/playbook" + } + ], + [ + { + "type": "playbook", + "context": "/path/to/playbook" + } + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/detail/properties/remediations/items", + "anyOf": [ + { + "$id": "#/properties/detail/properties/remediations/items/anyOf/0", + "type": "object", + "title": "The first remediation", + "description": "", + "default": {}, + "examples": [ + { + "type": "hint", + "context": "Please update your scripts to be compatible with the changes." + } + ], + "required": [ + "type", + "context" + ], + "properties": { + "type": { + "$id": "#/properties/detail/properties/remediations/items/anyOf/0/properties/type", + "type": "string", + "title": "The type schema", + "description": "Type of remediation.", + "default": "", + "enum": ["hint", "playbook"], + "examples": [ + "hint" + ] + }, + "context": { + "$id": "#/properties/detail/properties/remediations/items/anyOf/0/properties/context", + "type": "string", + "title": "The context schema", + "description": "The remediation itself.", + "default": "", + "examples": [ + "Please update your scripts to be compatible with the changes." + ] + } + }, + "additionalProperties": true + }, + { + "$id": "#/properties/detail/properties/remediations/items/anyOf/1", + "type": "object", + "title": "The first remediation", + "description": "", + "default": {}, + "examples": [ + { + "type": "command", + "context": [ "rm -rf /tmp/42" ] + } + ], + "required": [ + "type", + "context" + ], + "properties": { + "type": { + "$id": "#/properties/detail/properties/remediations/items/anyOf/1/properties/type", + "type": "string", + "title": "The type schema", + "description": "Type of remediation.", + "default": "", + "enum": ["command"], + "examples": ["command"] + }, + "context": { + "$id": "#/properties/detail/properties/remediations/items/anyOf/1/properties/context", + "type": "array", + "title": "The context schema", + "description": "List of remediation commands.", + "default": [], + "examples": [ + [ + "rm -rf /tmp/42" + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/detail/properties/remediations/items/anyOf/1/properties/context/items", + "anyOf": [ + { + "$id": "#/properties/detail/properties/remediations/items/anyOf/1/properties/context/items/anyOf/0", + "type": "string", + "title": "The remediation command schema", + "description": "The remediation in form of a command.", + "default": "", + "examples": [ + "rm -rf /tmp/42" + ] + } + ] + } + } + }, + "additionalProperties": true + } + ] + } + } + }, + "additionalProperties": true + }, + "actor": { + "$id": "#/properties/entries/items/anyOf/0/properties/actor", + "type": "string", + "title": "The actor name schema", + "description": "Name of the actor that reported a problem.", + "default": "", + "examples": [ + "repositories_blacklist" + ] + }, + "summary": { + "$id": "#/properties/entries/items/anyOf/0/properties/summary", + "type": "string", + "title": "The summary schema", + "description": "Details of the reported problem.", + "default": "", + "examples": [ + "The following repositories are not supported by Red Hat and are excluded from the list of repositories used during the upgrade.\n- codeready-builder-for-rhel-8-x86_64-rpms" + ] + }, + "audience": { + "$id": "#/properties/entries/items/anyOf/0/properties/audience", + "type": "string", + "title": "The audience schema", + "description": "The key audience of the reported problem.", + "default": "", + "enum": ["sysadmin", "developer"], + "examples": [ + "sysadmin" + ] + }, + "flags": { + "$id": "#/properties/entries/items/anyOf/0/properties/flags", + "type": "array", + "title": "Report flags schema", + "description": "List of flags, a flag is a predefined string", + "default": [], + "examples": [ + [ + "failure" + ] + ], + "additionalItems": true, + "items": { + "$id": "#/properties/entries/items/anyOf/0/properties/flags/items", + "anyOf": [ + { + "$id": "#/properties/entries/items/anyOf/0/properties/flags/items/anyOf/0", + "type": "string", + "title": "The report flag schema", + "description": "A report flag can have a predefined value.", + "default": "", + "enum": ["failure", "inhibitor"], + "examples": [ + "failure" + ] + } + ] + } + }, + "key": { + "$id": "#/properties/entries/items/anyOf/0/properties/key", + "type": "string", + "title": "The key schema", + "description": "The stable unique report entry key.", + "default": "", + "examples": [ + "a12013a95a6d305adc9f4f675186f89760af1a7e" + ] + }, + "id": { + "$id": "#/properties/entries/items/anyOf/0/properties/id", + "type": "string", + "title": "The id schema", + "description": "Unique id for the report entry. Not stable.", + "default": "", + "examples": [ + "88e518df66f34e0097ef7b4a4121f50eb5bcf9e8b2c017d1d07dca5e22db65e5" + ] + } + }, + "additionalProperties": true + } + ] + } + } + }, + "additionalProperties": true +} diff --git a/requirements-tests.txt b/requirements-tests.txt index bbdbdf55c..97d645319 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,7 +1,9 @@ -r requirements.txt -e . +jsonschema==3.2.0 mock +pyrsistent==0.16.1 pytest==3.6.4 pytest-flake8 pytest-cov==2.9.0 diff --git a/tests/data/report-schema/leapp-report-stable-key.json b/tests/data/report-schema/leapp-report-stable-key.json new file mode 100644 index 000000000..a433d19b5 --- /dev/null +++ b/tests/data/report-schema/leapp-report-stable-key.json @@ -0,0 +1,590 @@ +{ + "leapp_run_id": "f3c5841f-9d0f-42c4-9446-c69f5905b8d2", + "entries": [ + { + "hostname": "ivasilev-masterleappprerelease", + "severity": "high", + "tags": [ + "python" + ], + "timeStamp": "2021-02-03T10:41:28.815987Z", + "title": "Difference in Python versions and support in RHEL 8", + "detail": { + "related_resources": [ + { + "scheme": "package", + "title": "python" + }, + { + "scheme": "package", + "title": "python2" + }, + { + "scheme": "package", + "title": "python3" + } + ], + "external": [ + { + "url": "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_basic_system_settings/#using-python3", + "title": "Difference in Python versions and support in RHEL 8" + } + ], + "remediations": [ + { + "type": "hint", + "context": "Please run \"alternatives --set python /usr/bin/python3\" after upgrade" + } + ] + }, + "actor": "python_inform_user", + "summary": "In RHEL 8, there is no 'python' command. Python 3 (backward incompatible) is the primary Python version and Python 2 is available with limited support and limited set of packages. Read more here: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_basic_system_settings/#using-python3", + "audience": "developer", + "key": "0c98585b1d8d252eb540bf61560094f3495351f5", + "id": "b2bf3d63f24c1db20aec710db920a5378674118d15e20705b79ca4cdb5235a31" + }, + { + "hostname": "ivasilev-masterleappprerelease", + "severity": "high", + "title": "Packages not signed by Red Hat found on the system", + "timeStamp": "2021-02-03T10:41:31.406560Z", + "tags": [ + "sanity" + ], + "actor": "red_hat_signed_rpm_check", + "summary": "The following packages have not been signed by Red Hat and may be removed during the upgrade process in case Red Hat-signed packages to be removed during the upgrade depend on them:\n- cockpit-leapp\n- leapp\n- leapp-deps\n- leapp-repository\n- leapp-repository-deps\n- python2-leapp", + "audience": "sysadmin", + "key": "13f0791ae5f19f50e7d0d606fb6501f91b1efb2c", + "id": "c53aace32759102a15eda7d2099624ac9fdc5261fda4853434ebad13c2bc7a1b" + }, + { + "hostname": "ivasilev-masterleappprerelease", + "severity": "info", + "tags": [ + "authentication", + "security", + "tools" + ], + "timeStamp": "2021-02-03T10:41:31.867660Z", + "title": "Current PAM and nsswitch.conf configuration will be kept.", + "detail": { + "related_resources": [ + { + "scheme": "package", + "title": "authselect" + }, + { + "scheme": "package", + "title": "authconfig" + }, + { + "scheme": "file", + "title": "/etc/nsswitch.conf" + } + ] + }, + "actor": "authselect_check", + "summary": "There is a new tool called authselect in RHEL8 that replaced authconfig. The upgrade process was unable to find an authselect profile that would be equivalent to your current configuration. Therefore your configuration will be left intact.", + "audience": "sysadmin", + "key": "40c4ab1da4a30dc1ca40e543f6385e1336d8810c", + "id": "4730b112b4644cb5fe569f539f7c5fb9c3653fbebb8bc5669f64482a79dfdef4" + }, + { + "hostname": "ivasilev-masterleappprerelease", + "severity": "low", + "tags": [ + "services", + "email" + ], + "timeStamp": "2021-02-03T10:41:32.446634Z", + "title": "Postfix has incompatible changes in the next major version", + "detail": { + "related_resources": [ + { + "scheme": "package", + "title": "postfix" + } + ] + }, + "actor": "check_postfix", + "summary": "Postfix 3.x has so called \"compatibility safety net\" that runs Postfix programs with backwards-compatible default settings. It will log a warning whenever backwards-compatible default setting may be required for continuity of service. Based on this logging the system administrator can decide if any backwards-compatible settings need to be made permanent in main.cf or master.cf, before turning off the backwards-compatibility safety net.\nThe backward compatibility safety net is by default turned off in Red Hat Enterprise Linux 8.\nIt can be turned on by running: \"postconf -e compatibility_level=0\nIt can be turned off by running: \"postconf -e compatibility_level=2\n\nIn the Postfix MySQL database client, the default \"option_group\" value has changed to \"client\", i.e. it now reads options from the [client] group from the MySQL configuration file. To disable it, set \"option_group\" to the empty string.\n\nThe postqueue command no longer forces all message arrival times to be reported in UTC. To get the old behavior, set TZ=UTC in main.cf:import_environment.\n\nPostfix 3.2 enables elliptic curve negotiation. This changes the default smtpd_tls_eecdh_grade setting to \"auto\", and introduces a new parameter \"tls_eecdh_auto_curves\" with the names of curves that may be negotiated.\n\nThe \"master.cf\" chroot default value has changed from \"y\" (yes) to \"n\" (no). This applies to master.cf services where chroot field is not explicitly specified.\n\nThe \"append_dot_mydomain\" default value has changed from \"yes\" to \"no\". You may need changing it to \"yes\" if senders cannot use complete domain names in e-mail addresses.\n\nThe \"relay_domains\" default value has changed from \"$mydestination\" to the empty value. This could result in unexpected \"Relay access denied\" errors or ETRN errors, because now will postfix by default relay only for the localhost.\n\nThe \"mynetworks_style\" default value has changed from \"subnet\" to \"host\". This parameter is used to implement the \"permit_mynetworks\" feature. The change could result in unexpected \"access denied\" errors, because postfix will now by default trust only the local machine, not the remote SMTP clients on the same IP subnetwork.\n\nPostfix now supports dynamically loaded database plugins. Plugins are shipped in individual RPM sub-packages. Correct database plugins have to be installed, otherwise the specific database client will not work. For example for PostgreSQL map to work, the postfix-pgsql RPM package has to be installed.\n", + "audience": "sysadmin", + "key": "5721e0a07a67d82cf7e5ea6f17662cd4f82e0a33", + "id": "1c5cfd0b438a6b5a51f21b19dcc467020fdd007c88b53650abe825ef3eb23edf" + }, + { + "hostname": "ivasilev-masterleappprerelease", + "severity": "info", + "title": "SElinux relabeling has been scheduled", + "timeStamp": "2021-02-03T10:41:33.414806Z", + "tags": [ + "selinux", + "security" + ], + "actor": "check_se_linux", + "summary": "SElinux relabeling has been scheduled as the status was permissive/enforcing.", + "audience": "sysadmin", + "key": "c12a05a22be0b5bc0af3f1119898ea6d8639d9c4", + "id": "da79239740a8ea898f05dd56d5272e12e4eb3b25f44a00553c08a7085629456e" + }, + { + "hostname": "ivasilev-masterleappprerelease", + "severity": "low", + "title": "SElinux will be set to permissive mode", + "timeStamp": "2021-02-03T10:41:33.455495Z", + "tags": [ + "selinux", + "security" + ], + "actor": "check_se_linux", + "summary": "SElinux will be set to permissive mode. Current mode: enforcing. This action is required by the upgrade process", + "audience": "sysadmin", + "key": "39d7183dafba798aa4bbb1e70b0ef2bbe5b1772f", + "id": "585370523ef2c526eabad6657714cbd0cd7f847e86c92a9f287c8b0370f595e6" + }, + { + "hostname": "ivasilev-masterleappprerelease", + "severity": "high", + "tags": [ + "authentication", + "security", + "network", + "services" + ], + "timeStamp": "2021-02-03T10:41:34.652935Z", + "title": "Possible problems with remote login using root account", + "detail": { + "related_resources": [ + { + "scheme": "package", + "title": "openssh-server" + }, + { + "scheme": "file", + "title": "/etc/ssh/sshd_config" + } + ], + "remediations": [ + { + "type": "hint", + "context": "If you depend on remote root logins using passwords, consider setting up a different user for remote administration or adding \"PermitRootLogin yes\" to sshd_config." + } + ] + }, + "actor": "openssh_permit_root_login", + "summary": "OpenSSH configuration file does not explicitly state the option PermitRootLogin in sshd_config file, which will default in RHEL8 to \"prohibit-password\".", + "audience": "sysadmin", + "flags": [ + "inhibitor" + ], + "key": "3d21e8cc9e1c09dc60429de7716165787e99515f", + "id": "d167087cb6ae606377a1b61b050cabeb29a11d83d4e0f302ae6c385a88353cf8" + }, + { + "hostname": "ivasilev-masterleappprerelease", + "severity": "medium", + "tags": [ + "services", + "time management" + ], + "timeStamp": "2021-02-03T10:41:35.571250Z", + "title": "chrony using default configuration", + "detail": { + "related_resources": [ + { + "scheme": "package", + "title": "ntpd" + }, + { + "scheme": "package", + "title": "chrony" + }, + { + "scheme": "file", + "title": "/etc/chrony.conf" + } + ] + }, + "actor": "check_chrony", + "summary": "default chrony configuration in RHEL8 uses leapsectz directive, which cannot be used with leap smearing NTP servers, and uses a single pool directive instead of four server directives", + "audience": "sysadmin", + "key": "c4222ebd18730a76f6bc7b3b66df898b106e6554", + "id": "e28db93cdcecda460d3d0d0b468b76369a15ee41cd1e50cd865eb0a13eed2cb7" + }, + { + "hostname": "ivasilev-masterleappprerelease", + "severity": "low", + "tags": [ + "repository" + ], + "timeStamp": "2021-02-03T10:41:36.748925Z", + "title": "Some enabled RPM repositories are unknown to Leapp", + "detail": { + "related_resources": [ + { + "scheme": "package", + "title": "perl-HTTP-Tiny" + }, + { + "scheme": "package", + "title": "vim-common" + }, + { + "scheme": "package", + "title": "perl-Time-HiRes" + }, + { + "scheme": "package", + "title": "python2-libcomps" + }, + { + "scheme": "package", + "title": "libcomps" + }, + { + "scheme": "package", + "title": "perl-libs" + }, + { + "scheme": "package", + "title": "vim-filesystem" + }, + { + "scheme": "package", + "title": "dnf-data" + }, + { + "scheme": "package", + "title": "perl-Time-Local" + }, + { + "scheme": "package", + "title": "perl-parent" + }, + { + "scheme": "package", + "title": "cockpit-bridge" + }, + { + "scheme": "package", + "title": "perl-Pod-Simple" + }, + { + "scheme": "package", + "title": "json-glib" + }, + { + "scheme": "package", + "title": "perl-Filter" + }, + { + "scheme": "package", + "title": "gsettings-desktop-schemas" + }, + { + "scheme": "package", + "title": "perl" + }, + { + "scheme": "package", + "title": "perl-threads-shared" + }, + { + "scheme": "package", + "title": "libmodulemd" + }, + { + "scheme": "package", + "title": "python-enum34" + }, + { + "scheme": "package", + "title": "python2-libdnf" + }, + { + "scheme": "package", + "title": "dnf" + }, + { + "scheme": "package", + "title": "libsolv" + }, + { + "scheme": "package", + "title": "perl-macros" + }, + { + "scheme": "package", + "title": "perl-Encode" + }, + { + "scheme": "package", + "title": "perl-Error" + }, + { + "scheme": "package", + "title": "libproxy" + }, + { + "scheme": "package", + "title": "perl-Pod-Perldoc" + }, + { + "scheme": "package", + "title": "perl-Carp" + }, + { + "scheme": "package", + "title": "librhsm" + }, + { + "scheme": "package", + "title": "trousers" + }, + { + "scheme": "package", + "title": "perl-File-Path" + }, + { + "scheme": "package", + "title": "perl-constant" + }, + { + "scheme": "package", + "title": "perl-Storable" + }, + { + "scheme": "package", + "title": "python2-dnf" + }, + { + "scheme": "package", + "title": "glib-networking" + }, + { + "scheme": "package", + "title": "nmap-ncat" + }, + { + "scheme": "package", + "title": "perl-podlators" + }, + { + "scheme": "package", + "title": "perl-Exporter" + }, + { + "scheme": "package", + "title": "perl-Socket" + }, + { + "scheme": "package", + "title": "libdnf" + }, + { + "scheme": "package", + "title": "perl-Getopt-Long" + }, + { + "scheme": "package", + "title": "libreport-filesystem" + }, + { + "scheme": "package", + "title": "cockpit" + }, + { + "scheme": "package", + "title": "perl-Pod-Escapes" + }, + { + "scheme": "package", + "title": "git" + }, + { + "scheme": "package", + "title": "cockpit-ws" + }, + { + "scheme": "package", + "title": "bash-completion" + }, + { + "scheme": "package", + "title": "wget" + }, + { + "scheme": "package", + "title": "librepo" + }, + { + "scheme": "package", + "title": "perl-File-Temp" + }, + { + "scheme": "package", + "title": "perl-Pod-Usage" + }, + { + "scheme": "package", + "title": "vim-enhanced" + }, + { + "scheme": "package", + "title": "perl-PathTools" + }, + { + "scheme": "package", + "title": "perl-Text-ParseWords" + }, + { + "scheme": "package", + "title": "gpm-libs" + }, + { + "scheme": "package", + "title": "python2-hawkey" + }, + { + "scheme": "package", + "title": "perl-Git" + }, + { + "scheme": "package", + "title": "cockpit-system" + }, + { + "scheme": "package", + "title": "patch" + }, + { + "scheme": "package", + "title": "perl-TermReadKey" + }, + { + "scheme": "package", + "title": "nettle" + }, + { + "scheme": "package", + "title": "perl-threads" + }, + { + "scheme": "package", + "title": "libmodman" + }, + { + "scheme": "package", + "title": "gnutls" + }, + { + "scheme": "package", + "title": "pciutils" + }, + { + "scheme": "package", + "title": "perl-Scalar-List-Utils" + }, + { + "scheme": "repository", + "title": "rhel7-extras_rpms" + }, + { + "scheme": "repository", + "title": "rhel7server_rpms" + } + ], + "remediations": [ + { + "type": "hint", + "context": "You can file a request to add this repository to the scope of in-place upgrades by filing a support ticket" + } + ] + }, + "actor": "check_skipped_repositories", + "summary": "The following repositories with Red Hat-signed packages are unknown to Leapp:\n- rhel7-extras_rpms\n- rhel7server_rpms\nAnd the following packages installed from those repositories may not be upgraded:\n- perl-HTTP-Tiny\n- vim-common\n- perl-Time-HiRes\n- python2-libcomps\n- libcomps\n- perl-libs\n- vim-filesystem\n- dnf-data\n- perl-Time-Local\n- perl-parent\n- cockpit-bridge\n- perl-Pod-Simple\n- json-glib\n- perl-Filter\n- gsettings-desktop-schemas\n- perl\n- perl-threads-shared\n- libmodulemd\n- python-enum34\n- python2-libdnf\n- dnf\n- libsolv\n- perl-macros\n- perl-Encode\n- perl-Error\n- libproxy\n- perl-Pod-Perldoc\n- perl-Carp\n- librhsm\n- trousers\n- perl-File-Path\n- perl-constant\n- perl-Storable\n- python2-dnf\n- glib-networking\n- nmap-ncat\n- perl-podlators\n- perl-Exporter\n- perl-Socket\n- libdnf\n- perl-Getopt-Long\n- libreport-filesystem\n- cockpit\n- perl-Pod-Escapes\n- git\n- cockpit-ws\n- bash-completion\n- wget\n- librepo\n- perl-File-Temp\n- perl-Pod-Usage\n- vim-enhanced\n- perl-PathTools\n- perl-Text-ParseWords\n- gpm-libs\n- python2-hawkey\n- perl-Git\n- cockpit-system\n- patch\n- perl-TermReadKey\n- nettle\n- perl-threads\n- libmodman\n- gnutls\n- pciutils\n- perl-Scalar-List-Utils", + "audience": "sysadmin", + "key": "8e89e20c645cea600b240156071d81c64daab7ad", + "id": "207a1511c259d167e452fd56c365c1f41a0d8024d80cbe45f2dd1b7afa245ef6" + }, + { + "hostname": "ivasilev-masterleappprerelease", + "severity": "low", + "tags": [ + "tools" + ], + "timeStamp": "2021-02-03T10:41:37.796435Z", + "title": "Grep has incompatible changes in the next major version", + "detail": { + "related_resources": [ + { + "scheme": "package", + "title": "grep" + } + ], + "remediations": [ + { + "type": "hint", + "context": "Please update your scripts to be compatible with the changes." + } + ] + }, + "actor": "checkgrep", + "summary": "If a file contains data improperly encoded for the current locale, and this is discovered before any of the file's contents are output, grep now treats the file as binary.\nThe 'grep -P' no longer reports an error and exits when given invalid UTF-8 data. Instead, it considers the data to be non-matching.\nIn locales with multibyte character encodings other than UTF-8, grep -P now reports an error and exits instead of misbehaving.\nWhen searching binary data, grep now may treat non-text bytes as line terminators. This can boost performance significantly.\nThe 'grep -z' no longer automatically treats the byte '\\200' as binary data.\nContext no longer excludes selected lines omitted because of -m. For example, 'grep \"^\" -m1 -A1' now outputs the first two input lines, not just the first line.\n", + "audience": "sysadmin", + "key": "94665a499e2eeee35eca3e7093a7abe183384b16", + "id": "2c848d316714106b899d298f07523c1d3988699bf32684288b4b7ad9c034cbab" + }, + { + "hostname": "ivasilev-masterleappprerelease", + "severity": "high", + "title": "GRUB core will be updated during upgrade", + "timeStamp": "2021-02-03T10:41:38.043734Z", + "tags": [ + "boot" + ], + "actor": "check_grub_core", + "summary": "On legacy (BIOS) systems, GRUB core (located in the gap between the MBR and the first partition) does not get automatically updated when GRUB is upgraded.", + "audience": "sysadmin", + "key": "baa75fad370c42fd037481909201cde9495dacf4", + "id": "d56dc1491457c1af7559c8146900e1588cda6105ef9850b2da97230896e08598" + }, + { + "severity": "high", + "title": "Missing required answers in the answer file", + "timeStamp": "2021-02-03T10:41:38.629899Z", + "hostname": "ivasilev-masterleappprerelease", + "detail": { + "related_resources": [ + { + "scheme": "dialog", + "title": "remove_pam_pkcs11_module_check.confirm" + } + ], + "remediations": [ + { + "type": "hint", + "context": "Please register user choices with leapp answer cli command or by manually editing the answerfile." + }, + { + "type": "command", + "context": [ + "leapp", + "answer", + "--section", + "remove_pam_pkcs11_module_check.confirm=True" + ] + } + ] + }, + "actor": "verify_check_results", + "summary": "One or more sections in answerfile are missing user choices: remove_pam_pkcs11_module_check.confirm\nFor more information consult https://leapp.readthedocs.io/en/latest/dialogs.html", + "audience": "sysadmin", + "flags": [ + "inhibitor" + ], + "key": "d35f6c6b1b1fa6924ef442e3670d90fa92f0d54b", + "id": "e6f361340317b64fbdfad76ad63ff38f81a43a58ea2ca514ef8e5cc505e33dea" + } + ] +} \ No newline at end of file diff --git a/tests/data/report-schema/schemas/report-schema-v100.json b/tests/data/report-schema/schemas/report-schema-v100.json new file mode 120000 index 000000000..feb47d7eb --- /dev/null +++ b/tests/data/report-schema/schemas/report-schema-v100.json @@ -0,0 +1 @@ +../../../../report-schema-v100.json \ No newline at end of file diff --git a/tests/data/report-schema/schemas/report-schema-v110.json b/tests/data/report-schema/schemas/report-schema-v110.json new file mode 120000 index 000000000..714796041 --- /dev/null +++ b/tests/data/report-schema/schemas/report-schema-v110.json @@ -0,0 +1 @@ +../../../../report-schema-v110.json \ No newline at end of file diff --git a/tests/scripts/test_reporting.py b/tests/scripts/test_reporting.py index e75ae24d1..72e9f4a2f 100644 --- a/tests/scripts/test_reporting.py +++ b/tests/scripts/test_reporting.py @@ -1,6 +1,9 @@ from collections import namedtuple import datetime +import json +import os +import jsonschema import pytest from leapp.reporting import ( @@ -198,3 +201,22 @@ def test_create_report_stable_key(monkeypatch): with pytest.raises(ValueError) as err: Key(bad_uuid) assert str(err.value) == 'Key value should be a string.' + + +def test_report_jsonschema(): + reports_dir = os.path.join( + os.path.dirname(os.path.dirname(__file__)), + 'data', + 'report-schema', + ) + + def _load_json(a_file): + with open(a_file) as f: + return json.loads(f.read()) + + for report in [r for r in os.listdir(reports_dir) if os.path.isfile(r)]: + report_data = _load_json(os.path.join(reports_dir, report)) + for schema in ['report-schema-v100.json', 'report-schema-v110.json']: + # schemas directory contain a symlink to report json-schemas + schema_data = _load_json(os.path.join(reports_dir, 'schemas', schema)) + jsonschema.validate(report_data, schema_data)