salt/noxfile.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

2018 lines
64 KiB
Python
Raw Normal View History

2020-04-02 20:10:20 -05:00
"""
noxfile
~~~~~~~
Nox configuration script
2020-04-02 20:10:20 -05:00
"""
2024-02-27 10:24:22 +00:00
2020-04-09 11:32:38 +01:00
# pylint: disable=resource-leakage,3rd-party-module-not-gated
import contextlib
import datetime
import glob
import gzip
import json
import os
import pathlib
import shutil
import sqlite3
import sys
import tarfile
import tempfile
2019-03-16 19:00:01 +00:00
2023-01-23 08:24:35 -07:00
import nox.command
2020-04-02 20:10:20 -05:00
# fmt: off
2020-04-09 11:32:38 +01:00
if __name__ == "__main__":
sys.stderr.write(
"Do not execute this file directly. Use nox instead, it will know how to handle this file\n"
)
sys.stderr.flush()
exit(1)
2020-04-02 20:10:20 -05:00
# fmt: on
import nox # isort:skip
2019-03-22 17:27:01 +00:00
from nox.command import CommandFailed # isort:skip
2020-04-02 20:10:20 -05:00
REPO_ROOT = pathlib.Path(__file__).resolve().parent
ENV_FILE = REPO_ROOT / ".ci-env"
if ENV_FILE.exists():
print("Found .ci-env file. Updating environment...", flush=True)
for key, value in json.loads(ENV_FILE.read_text()).items():
print(f" {key}={value}", flush=True)
os.environ[key] = value
print("Deleting .ci-env file", flush=True)
ENV_FILE.unlink()
2023-12-19 16:13:09 +01:00
# Be verbose when running under a CI context
CI_RUN = (
os.environ.get("JENKINS_URL")
or os.environ.get("CI")
or os.environ.get("DRONE") is not None
)
PIP_INSTALL_SILENT = CI_RUN is False
PRINT_TEST_SELECTION = os.environ.get("PRINT_TEST_SELECTION")
if PRINT_TEST_SELECTION is None:
PRINT_TEST_SELECTION = CI_RUN
else:
PRINT_TEST_SELECTION = PRINT_TEST_SELECTION == "1"
PRINT_TEST_PLAN_ONLY = os.environ.get("PRINT_TEST_PLAN_ONLY", "0") == "1"
PRINT_SYSTEM_INFO = os.environ.get("PRINT_SYSTEM_INFO")
if PRINT_SYSTEM_INFO is None:
PRINT_SYSTEM_INFO = CI_RUN
else:
PRINT_SYSTEM_INFO = PRINT_SYSTEM_INFO == "1"
PRINT_SYSTEM_INFO_ONLY = os.environ.get("PRINT_SYSTEM_INFO_ONLY", "0") == "1"
SKIP_REQUIREMENTS_INSTALL = os.environ.get("SKIP_REQUIREMENTS_INSTALL", "0") == "1"
EXTRA_REQUIREMENTS_INSTALL = os.environ.get("EXTRA_REQUIREMENTS_INSTALL")
COVERAGE_REQUIREMENT = os.environ.get("COVERAGE_REQUIREMENT")
# Global Path Definitions
REPO_ROOT = pathlib.Path(os.path.dirname(__file__)).resolve()
ARTIFACTS_DIR = REPO_ROOT / "artifacts"
COVERAGE_OUTPUT_DIR = ARTIFACTS_DIR / "coverage"
COVERAGE_FILE = os.environ.get("COVERAGE_FILE")
if COVERAGE_FILE is None:
COVERAGE_FILE = str(COVERAGE_OUTPUT_DIR / ".coverage")
IS_DARWIN = sys.platform.lower().startswith("darwin")
2019-03-01 23:25:31 +00:00
IS_WINDOWS = sys.platform.lower().startswith("win")
2020-06-03 13:58:37 +01:00
IS_FREEBSD = sys.platform.lower().startswith("freebsd")
IS_LINUX = sys.platform.lower().startswith("linux")
ONEDIR_ARTIFACT_PATH = ARTIFACTS_DIR / "salt"
if IS_WINDOWS:
ONEDIR_PYTHON_PATH = ONEDIR_ARTIFACT_PATH / "Scripts" / "python.exe"
else:
ONEDIR_PYTHON_PATH = ONEDIR_ARTIFACT_PATH / "bin" / "python3"
# Python versions to run against
_PYTHON_VERSIONS = ("3", "3.8", "3.9", "3.10", "3.11")
# Nox options
# Reuse existing virtualenvs
nox.options.reuse_existing_virtualenvs = True
2019-10-31 10:14:36 +00:00
# Change current directory to REPO_ROOT
os.chdir(str(REPO_ROOT))
2019-10-31 10:14:36 +00:00
RUNTESTS_LOGFILE = ARTIFACTS_DIR.joinpath(
2019-06-08 18:19:01 +01:00
"logs",
"runtests-{}.log".format(datetime.datetime.now().strftime("%Y%m%d%H%M%S.%f")),
)
# Prevent Python from writing bytecode
2020-08-14 15:19:49 +01:00
os.environ["PYTHONDONTWRITEBYTECODE"] = "1"
2019-03-16 19:00:01 +00:00
def session_warn(session, message):
try:
session.warn(message)
except AttributeError:
session.log(f"WARNING: {message}")
def session_run_always(session, *command, **kwargs):
"""
Patch nox to allow running some commands which would be skipped if --install-only is passed.
"""
try:
# Guess we weren't the only ones wanting this
# https://github.com/theacodes/nox/pull/331
return session.run_always(*command, **kwargs)
except AttributeError:
old_install_only_value = session._runner.global_config.install_only
try:
# Force install only to be false for the following chunk of code
# For additional information as to why see:
# https://github.com/theacodes/nox/pull/181
session._runner.global_config.install_only = False
return session.run(*command, **kwargs)
finally:
session._runner.global_config.install_only = old_install_only_value
def find_session_runner(session, name, python_version, onedir=False, **kwargs):
if onedir:
name += f"-onedir-{ONEDIR_PYTHON_PATH}"
else:
name += f"-{python_version}"
for s, _ in session._runner.manifest.list_all_sessions():
if name not in s.signatures:
continue
for signature in s.signatures:
for key, value in kwargs.items():
param = f"{key}={value!r}"
if param not in signature:
break
else:
return s
continue
session.error(
"Could not find a nox session by the name {!r} with the following keyword arguments: {!r}".format(
name, kwargs
)
)
def _create_ci_directories():
ARTIFACTS_DIR.mkdir(parents=True, exist_ok=True)
# Allow other users to write to this directory.
# This helps when some tests run under a different name and yet
# they need access to this path, for example, code coverage.
ARTIFACTS_DIR.chmod(0o777)
COVERAGE_OUTPUT_DIR.mkdir(exist_ok=True)
COVERAGE_OUTPUT_DIR.chmod(0o777)
ARTIFACTS_DIR.joinpath("xml-unittests-output").mkdir(exist_ok=True)
def _get_session_python_version_info(session):
try:
version_info = session._runner._real_python_version_info
except AttributeError:
session_py_version = session_run_always(
session,
"python",
"-c",
'import sys; sys.stdout.write("{}.{}.{}".format(*sys.version_info))',
stderr=None,
silent=True,
log=False,
)
version_info = tuple(
int(part)
for part in session_py_version.strip().split(".")
if part.isdigit()
)
session._runner._real_python_version_info = version_info
return version_info
def _get_pydir(session):
version_info = _get_session_python_version_info(session)
if version_info < (3, 8):
session.error("Only Python >= 3.8 is supported")
return "py{}.{}".format(*version_info)
def _get_pip_requirements_file(session, crypto=None, requirements_type="ci"):
assert requirements_type in ("ci", "pkg")
pydir = _get_pydir(session)
if IS_WINDOWS:
if crypto is None:
_requirements_file = os.path.join(
"requirements", "static", requirements_type, pydir, "windows.txt"
)
if os.path.exists(_requirements_file):
return _requirements_file
_requirements_file = os.path.join(
"requirements", "static", requirements_type, pydir, "windows-crypto.txt"
)
if os.path.exists(_requirements_file):
return _requirements_file
session.error(f"Could not find a windows requirements file for {pydir}")
elif IS_DARWIN:
if crypto is None:
_requirements_file = os.path.join(
"requirements", "static", requirements_type, pydir, "darwin.txt"
)
if os.path.exists(_requirements_file):
return _requirements_file
_requirements_file = os.path.join(
"requirements", "static", requirements_type, pydir, "darwin-crypto.txt"
)
if os.path.exists(_requirements_file):
return _requirements_file
session.error(f"Could not find a darwin requirements file for {pydir}")
2020-06-03 13:58:37 +01:00
elif IS_FREEBSD:
if crypto is None:
_requirements_file = os.path.join(
"requirements", "static", requirements_type, pydir, "freebsd.txt"
2020-06-03 13:58:37 +01:00
)
if os.path.exists(_requirements_file):
return _requirements_file
_requirements_file = os.path.join(
"requirements", "static", requirements_type, pydir, "freebsd-crypto.txt"
2020-06-03 13:58:37 +01:00
)
if os.path.exists(_requirements_file):
return _requirements_file
session.error(f"Could not find a freebsd requirements file for {pydir}")
else:
if crypto is None:
_requirements_file = os.path.join(
"requirements", "static", requirements_type, pydir, "linux.txt"
)
if os.path.exists(_requirements_file):
return _requirements_file
_requirements_file = os.path.join(
"requirements", "static", requirements_type, pydir, "linux-crypto.txt"
)
if os.path.exists(_requirements_file):
return _requirements_file
session.error(f"Could not find a linux requirements file for {pydir}")
2019-03-16 19:00:01 +00:00
2019-10-07 18:29:02 +01:00
def _upgrade_pip_setuptools_and_wheel(session, upgrade=True):
if SKIP_REQUIREMENTS_INSTALL:
session.log(
"Skipping Python Requirements because SKIP_REQUIREMENTS_INSTALL was found in the environ"
)
return False
2020-08-31 17:56:16 +01:00
env = os.environ.copy()
env["PIP_CONSTRAINT"] = str(REPO_ROOT / "requirements" / "constraints.txt")
install_command = [
"python",
"-m",
"pip",
"install",
"--progress-bar=off",
]
if upgrade:
install_command.append("-U")
install_command.extend(["setuptools", "pip", "wheel"])
session_run_always(session, *install_command, silent=PIP_INSTALL_SILENT, env=env)
return True
2020-08-31 17:56:16 +01:00
Merge 3003.3 into master (#60924) * Merge 3002.6 bugfix changes (#59822) * Pass `CI_RUN` as an environment variable to the test run. This allows us to know if we're running the test suite under a CI environment or not and adapt/adjust if needed * Migrate `unit.setup` to PyTest * Backport ae36b15 just for test_install.py * Only skip tests on CI runs * Always store git sha in _version.py during installation * Fix PEP440 compliance. The wheel metadata version 1.2 states that the package version MUST be PEP440 compliant. This means that instead of `3002.2-511-g033c53eccb`, the salt version string should look like `3002.2+511.g033c53eccb`, a post release of `3002.2` ahead by 511 commits with the git sha `033c53eccb` * Fix and migrate `tests/unit/test_version.py` to PyTest * Skip test if `easy_install` is not available * We also need to be PEP440 compliant when there's no git history * Allow extra_filerefs as sanitized kwargs for SSH client * Fix regression on cmd.run when passing tuples as cmd Co-authored-by: Alexander Graul <agraul@suse.com> * Add unit tests to ensure cmd.run accepts tuples * Add unit test to check for extra_filerefs on SSH opts * Add changelog file * Fix comment for test case * Fix unit test to avoid failing on Windows * Skip failing test on windows * Fix test to work on Windows * Add all ssh kwargs to sanitize_kwargs method * Run pre-commit * Fix pylint * Fix cmdmod loglevel and module_names tests * Fix pre-commit * Skip ssh tests if binary does not exist * Use setup_loader for cmdmod test * Prevent argument injection in restartcheck * Add changelog for restartcheck fix * docs_3002.6 * Add back tests removed in merge Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> * Remove glance state module in favor of glance_image * update wording in changelog * bump deprecation warning to Silicon. * Updating warnutil version to Phosphorous. * Update salt/modules/keystone.py Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Check $HOMEBREW_PREFIX when linking against libcrypto When loading `libcrypto`, Salt checks for a Homebrew installation of `openssl` at Homebrew's default prefix of `/usr/local`. However, on Apple Silicon Macs, Homebrew's default installation prefix is `/opt/homebrew`. On all platforms, the prefix is configurable. If Salt doesn't find one of those `libcrypto`s, it will fall back on the un-versioned `/usr/lib/libcrypto.dylib`, which will cause the following crash: Application Specific Information: /usr/lib/libcrypto.dylib abort() called Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI. This commit checks $HOMEBREW_PREFIX instead of hard-coding `/usr/local`. * Add test case * Add changelog for 59808 * Add changelog entry * Make _find_libcrypto fail on Big Sur if it can't find a library Right now, if `_find_libcrypto` can't find any externally-managed versions of libcrypto, it will fall back on the pre-Catalina un-versioned system libcrypto. This does not exist on Big Sur and it would be better to raise an exception here rather than crashing later when trying to open it. * Update _find_libcrypto tests This commit simplifies the unit tests for _find_libcrypto by mocking out the host's filesystem and testing the common libcrypto installations (brew, ports, etc.) on Big Sur. It simplifies the tests for falling back on system versions of libcrypto on previous versions of macOS. * Fix description of test_find_libcrypto_with_system_before_catalina * Patch sys.platform for test_rsax931 tests * modules/match: add missing "minion_id" in Pillar example The documented Pillar example for `match.filter_by` lacks the `minion_id` parameter. Without it, the assignment won't work as expected. - fix documentation - add tests: - to prove the misbehavior of the documented example - to prove the proper behaviour when supplying `minion_id` - to ensure some misbehaviour observed with compound matchers doesn't occur * Fix for issue #59773 - When instantiating the loader grab values of grains and pillars if they are NamedLoaderContext instances. - The loader uses a copy of opts. - Impliment deepcopy on NamedLoaderContext instances. * Add changelog for #59773 * _get_initial_pillar function returns pillar * Fix linter issues * Clean up test * Bump deprecation release for neutron * Uncomment Sulfur release name * Removing the _ext_nodes deprecation warning and alias. * Adding changelog. * Renaming changelog file. * Update 59804.removed * Initial pass at fips_mode config option * Fix pre-commit * Fix tests and add changelog * update docs 3003 * update docs 3003 - newline * Fix warts in changelog * update releasenotes 3003 * add ubuntu-2004-amd64 m2crypto pycryptodome and tcp tests * add distro_arch * changing the cloud platforms file missed in 1a9b7be0e2f300d87924731dc5816fd1000cd22b * Update __utils__ calls to import utils in azure * Add changelog for 59744 * Fix azure unit tests and move to pytest * Use contextvars from site-packages for thin If a contextvars package exists one of the site-packages locations use it for the generated thin tarball. This overrides python's builtin contextvars and allows salt-ssh to work with python <=3.6 even when the master's python is >3.6 (Fixes #59942) * Add regression test for #59942 * Add changelog for #59942 * Update filemap to include test_py_versions * Fix broken thin tests * Always install the `contextvars` backport, even on Py3.7+ Without this change, salt-ssh cannot target systems with Python <= 3.6 * Use salt-factories to handle the container. Don't override default roster * Fix thin tests on windows * No need to use warn log level here * Fix getsitepackages for old virtualenv versions * Add explicit pyobjc reqs * Add back the passthrough stuff * Remove a line so pre-commit will run * Bugfix release docs * Bugfix release docs * Removing pip-compile log files * Bump requirements to address a few security issues * Address traceback on macOS ``` Traceback (most recent call last): File "setup.py", line 1448, in <module> setup(distclass=SaltDistribution) File "/Users/jenkins/setup-tests/.venv/lib/python3.7/site-packages/setuptools/__init__.py", line 153, in setup return distutils.core.setup(**attrs) File "/opt/salt/lib/python3.7/distutils/core.py", line 108, in setup _setup_distribution = dist = klass(attrs) File "setup.py", line 1068, in __init__ self.update_metadata() File "setup.py", line 1074, in update_metadata attrvalue = getattr(self, attrname, None) File "setup.py", line 1182, in _property_install_requires install_requires += _parse_requirements_file(reqfile) File "setup.py", line 270, in _parse_requirements_file platform.python_version(), _parse_op(op), _parse_ver(ver) File "setup.py", line 247, in _check_ver return getattr(operator, "__{}__".format(op))(pyver, wanted) File "/opt/salt/lib/python3.7/distutils/version.py", line 46, in __eq__ c = self._cmp(other) File "/opt/salt/lib/python3.7/distutils/version.py", line 337, in _cmp if self.version < other.version: TypeError: '<' not supported between instances of 'str' and 'int' ``` * Replace `saltstack.com` with `saltproject.io` on URLs being tested * Add back support to load old entrypoints by iterating instead of type checking Fixes #59961 * Fix issue #59975 * Fix pillar serialization for jinja #60083 * Fix test * Add changelog for #60083 * Update changelog and release for 3003.1 * Remove the changelog source refs * Add connect to IPCMessageSubscriber's async_methods Fixes #60049 by making sure an IPCMessageSubscriber that is wrapped by SyncWrapper has a connect method that runs the coroutine rather than returns a fugure. * Add changelog for #60049 * Update 60049.fixed * Fix coroutine spelling error Co-authored-by: Wayne Werner <waynejwerner@gmail.com> * IPC on windows cannot use socket paths Fixes #60298 * Update Jinja2 and lxml due to security related bugfix releases Jinja2 ------ CVE-2020-28493 moderate severity Vulnerable versions: < 2.11.3 Patched version: 2.11.3 This affects the package jinja2 from 0.0.0 and before 2.11.3. The ReDOS vulnerability of the regex is mainly due to the sub-pattern [a-zA-Z0-9.-]+.[a-zA-Z0-9.-]+ This issue can be mitigated by Markdown to format user content instead of the urlize filter, or by implementing request timeouts and limiting process memory. lxml ---- CVE-2021-28957 moderate severity Vulnerable versions: < 4.6.3 Patched version: 4.6.3 An XSS vulnerability was discovered in the python lxml clean module versions before 4.6.3. When disabling the safe_attrs_only and forms arguments, the Cleaner class does not remove the formaction attribute allowing for JS to bypass the sanitizer. A remote attacker could exploit this flaw to run arbitrary JS code on users who interact with incorrectly sanitized HTML. This issue is patched in lxml 4.6.3. * fix github actions jobs on branch until bullseye comes out * Upgrade to `six==1.16.0` to avoid problems on CI runs ``` 13:59:02 nox > Session invoke-pre-commit was successful. 13:59:02 nox > Running session invoke-pre-commit 13:59:02 nox > pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt 13:59:02 Collecting blessings==1.7 13:59:02 Using cached blessings-1.7-py3-none-any.whl (18 kB) 13:59:02 Collecting invoke==1.4.1 13:59:02 Using cached invoke-1.4.1-py3-none-any.whl (210 kB) 13:59:02 Collecting pyyaml==5.3.1 13:59:02 Using cached PyYAML-5.3.1.tar.gz (269 kB) 13:59:02 Collecting six==1.15.0 13:59:02 Using cached six-1.15.0-py2.py3-none-any.whl (10 kB) 13:59:02 Building wheels for collected packages: pyyaml 13:59:02 Building wheel for pyyaml (setup.py) ... - \ | / - \ | done 13:59:02 Created wheel for pyyaml: filename=PyYAML-5.3.1-cp37-cp37m-linux_x86_64.whl size=546391 sha256=e42e1d66cc32087f4d33ceb81268c86b59f1a97029b19459f91b8d6ad1430167 13:59:02 Stored in directory: /var/jenkins/.cache/pip/wheels/5e/03/1e/e1e954795d6f35dfc7b637fe2277bff021303bd9570ecea653 13:59:02 Successfully built pyyaml 13:59:02 Installing collected packages: six, pyyaml, invoke, blessings 13:59:02 Attempting uninstall: six 13:59:02 Found existing installation: six 1.16.0 13:59:02 Uninstalling six-1.16.0: 13:59:02 ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/var/jenkins/.cache/pre-commit/repomw8oee1s/py_env-python3/lib/python3.7/site-packages/__pycache__/six.cpython-37.pyc' 13:59:02 13:59:02 nox > Command pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt failed with exit code 1 13:59:02 nox > Session invoke-pre-commit failed. ``` * add changelog for https://github.com/saltstack/salt/issues/59982 * Regression test for #56273 * Fix race condition in batch. #56273 * Add changelog for #56273 * Update salt/client/__init__.py Co-authored-by: Pedro Algarvio <pedro@algarvio.me> * Update doc for salt/client * Update changelog/56273.fixed Thoreau said, "Simplify, Simplify" * Update docs * Update docs * Update CHANGELOG.md * Update 3003.1.rst * Ignore configuration for 'enable_fqdns_grains' for AIX, Solaris and Juniper * Added changelog * Let Mac OS Mojave run for 8 hours to avoid timeout * Remove FreeBSD-12.2 * Use Popen for VT * Still allow shell True * Drop shlex split * Add crypto re-init * Fix pre-commit * Do not call close in isalive * Skip tests not valid on windows * Cleanup things that are not really needed * We do not support irix * Fix pre-commit * Remove commented out lines * Add changelog for #60504 * Fix pre-commit issues * pyupgrade does not remove six imports * Fix OSErrors in some test cases * Remove un-needed args processing * Make state_running test more reliable * Removing tmpfs from Fedora 33. * Address leaks in fileserver caused by git backends At this time we do not have the ability to fix the upstream memory leaks in the gitfs backend providers. Work around their limitations by periodically restarting the file server update proccess. This will at least partially address #50313 * Remove un-used import * Fix warts caused by black version * Add changelog * We don't need two changelogs * Also pin the ``pip`` upgrade to be ``<21.2`` * Update the external ipaddress to the latest 3.9.5 version which has some security fixes. Updating the compat.p to use the vendored version if the python version is below 3.9.5 and only run the test_ipaddress.py tests if below 3.9.5. * Adding changelog * Requested changes. * Add shh_timeout to ssh_kwargs * move to with blocks * one with block * reight crypto * add back test file * add changelog * change log file number * add m2crypt support * only check m2crpto * Delete 60571.fixed * add back log * add newline * add newline for log file * Work around https://github.com/pypa/pip/pull/9450 See https://github.com/pypa/pip/issues/10212 * Drop six and Py2 * [3003.2] Add server alive (#60573) * add server alive * rename log * change default alive time * add requested changes * format string * reformat string again * run pre * customize * space * remove EOF dead space * fix pre-commit * run pre Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Changelog for 3003.2 * Man pages update for 3003.2 * Allow CVE entries in `changelog/` * Add security type for towncrier changelog * Add security type for changelog entries pre-commit check * Pin to ``pip>=20.2.4,<21.2`` Refs https://github.com/pypa/pip/pull/9450 * Drop six and Py2 * Fix bug introduced in https://github.com/saltstack/salt/pull/59648 Fixes #60046 * Add changelog * Fix doc builds * fix release notes about dropping ubuntu 16.04 * update file client * add changelog file * update changelog * Check permissions of minion config directory * Fix some wording in the messagebox and in comments * Add changelog * Fix extension for changelog * Add missing commas. It also worked, but now is better * docs_3003.3 * fixing version numbers in man pages. * removing newlines. * removing newlines. * Fixing release notes. * Fix changelog file for 3003.2 release * Fix test_state test using loader.context * Re-add test_context test * Allow Local System account, add timestamp * swaping the git-source for vsphere-automation-sdk-python * Remove destroy, handled in context manager Co-authored-by: Daniel Wozniak <dwozniak@saltstack.com> Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@wiked.org> Co-authored-by: Hoa-Long Tam <hoalong@apple.com> Co-authored-by: krionbsd <krion@freebsd.org> Co-authored-by: Elias Probst <e.probst@ssc-services.de> Co-authored-by: Daniel A. Wozniak <dwozniak@vmware.com> Co-authored-by: Frode Gundersen <frogunder@gmail.com> Co-authored-by: twangboy <slee@saltstack.com> Co-authored-by: twangboy <leesh@vmware.com> Co-authored-by: ScriptAutomate <derek@icanteven.io> Co-authored-by: Wayne Werner <waynejwerner@gmail.com> Co-authored-by: David Murphy < dmurphy@saltstack.com> Co-authored-by: Joe Eacott <jeacott@vmware.com> Co-authored-by: cmcmarrow <charles.mcmarrow.4@gmail.com> Co-authored-by: Twangboy <shane.d.lee@gmail.com>
2021-09-22 20:42:38 -04:00
def _install_requirements(
session,
*extra_requirements,
requirements_type="ci",
onedir=False,
Merge 3003.3 into master (#60924) * Merge 3002.6 bugfix changes (#59822) * Pass `CI_RUN` as an environment variable to the test run. This allows us to know if we're running the test suite under a CI environment or not and adapt/adjust if needed * Migrate `unit.setup` to PyTest * Backport ae36b15 just for test_install.py * Only skip tests on CI runs * Always store git sha in _version.py during installation * Fix PEP440 compliance. The wheel metadata version 1.2 states that the package version MUST be PEP440 compliant. This means that instead of `3002.2-511-g033c53eccb`, the salt version string should look like `3002.2+511.g033c53eccb`, a post release of `3002.2` ahead by 511 commits with the git sha `033c53eccb` * Fix and migrate `tests/unit/test_version.py` to PyTest * Skip test if `easy_install` is not available * We also need to be PEP440 compliant when there's no git history * Allow extra_filerefs as sanitized kwargs for SSH client * Fix regression on cmd.run when passing tuples as cmd Co-authored-by: Alexander Graul <agraul@suse.com> * Add unit tests to ensure cmd.run accepts tuples * Add unit test to check for extra_filerefs on SSH opts * Add changelog file * Fix comment for test case * Fix unit test to avoid failing on Windows * Skip failing test on windows * Fix test to work on Windows * Add all ssh kwargs to sanitize_kwargs method * Run pre-commit * Fix pylint * Fix cmdmod loglevel and module_names tests * Fix pre-commit * Skip ssh tests if binary does not exist * Use setup_loader for cmdmod test * Prevent argument injection in restartcheck * Add changelog for restartcheck fix * docs_3002.6 * Add back tests removed in merge Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> * Remove glance state module in favor of glance_image * update wording in changelog * bump deprecation warning to Silicon. * Updating warnutil version to Phosphorous. * Update salt/modules/keystone.py Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Check $HOMEBREW_PREFIX when linking against libcrypto When loading `libcrypto`, Salt checks for a Homebrew installation of `openssl` at Homebrew's default prefix of `/usr/local`. However, on Apple Silicon Macs, Homebrew's default installation prefix is `/opt/homebrew`. On all platforms, the prefix is configurable. If Salt doesn't find one of those `libcrypto`s, it will fall back on the un-versioned `/usr/lib/libcrypto.dylib`, which will cause the following crash: Application Specific Information: /usr/lib/libcrypto.dylib abort() called Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI. This commit checks $HOMEBREW_PREFIX instead of hard-coding `/usr/local`. * Add test case * Add changelog for 59808 * Add changelog entry * Make _find_libcrypto fail on Big Sur if it can't find a library Right now, if `_find_libcrypto` can't find any externally-managed versions of libcrypto, it will fall back on the pre-Catalina un-versioned system libcrypto. This does not exist on Big Sur and it would be better to raise an exception here rather than crashing later when trying to open it. * Update _find_libcrypto tests This commit simplifies the unit tests for _find_libcrypto by mocking out the host's filesystem and testing the common libcrypto installations (brew, ports, etc.) on Big Sur. It simplifies the tests for falling back on system versions of libcrypto on previous versions of macOS. * Fix description of test_find_libcrypto_with_system_before_catalina * Patch sys.platform for test_rsax931 tests * modules/match: add missing "minion_id" in Pillar example The documented Pillar example for `match.filter_by` lacks the `minion_id` parameter. Without it, the assignment won't work as expected. - fix documentation - add tests: - to prove the misbehavior of the documented example - to prove the proper behaviour when supplying `minion_id` - to ensure some misbehaviour observed with compound matchers doesn't occur * Fix for issue #59773 - When instantiating the loader grab values of grains and pillars if they are NamedLoaderContext instances. - The loader uses a copy of opts. - Impliment deepcopy on NamedLoaderContext instances. * Add changelog for #59773 * _get_initial_pillar function returns pillar * Fix linter issues * Clean up test * Bump deprecation release for neutron * Uncomment Sulfur release name * Removing the _ext_nodes deprecation warning and alias. * Adding changelog. * Renaming changelog file. * Update 59804.removed * Initial pass at fips_mode config option * Fix pre-commit * Fix tests and add changelog * update docs 3003 * update docs 3003 - newline * Fix warts in changelog * update releasenotes 3003 * add ubuntu-2004-amd64 m2crypto pycryptodome and tcp tests * add distro_arch * changing the cloud platforms file missed in 1a9b7be0e2f300d87924731dc5816fd1000cd22b * Update __utils__ calls to import utils in azure * Add changelog for 59744 * Fix azure unit tests and move to pytest * Use contextvars from site-packages for thin If a contextvars package exists one of the site-packages locations use it for the generated thin tarball. This overrides python's builtin contextvars and allows salt-ssh to work with python <=3.6 even when the master's python is >3.6 (Fixes #59942) * Add regression test for #59942 * Add changelog for #59942 * Update filemap to include test_py_versions * Fix broken thin tests * Always install the `contextvars` backport, even on Py3.7+ Without this change, salt-ssh cannot target systems with Python <= 3.6 * Use salt-factories to handle the container. Don't override default roster * Fix thin tests on windows * No need to use warn log level here * Fix getsitepackages for old virtualenv versions * Add explicit pyobjc reqs * Add back the passthrough stuff * Remove a line so pre-commit will run * Bugfix release docs * Bugfix release docs * Removing pip-compile log files * Bump requirements to address a few security issues * Address traceback on macOS ``` Traceback (most recent call last): File "setup.py", line 1448, in <module> setup(distclass=SaltDistribution) File "/Users/jenkins/setup-tests/.venv/lib/python3.7/site-packages/setuptools/__init__.py", line 153, in setup return distutils.core.setup(**attrs) File "/opt/salt/lib/python3.7/distutils/core.py", line 108, in setup _setup_distribution = dist = klass(attrs) File "setup.py", line 1068, in __init__ self.update_metadata() File "setup.py", line 1074, in update_metadata attrvalue = getattr(self, attrname, None) File "setup.py", line 1182, in _property_install_requires install_requires += _parse_requirements_file(reqfile) File "setup.py", line 270, in _parse_requirements_file platform.python_version(), _parse_op(op), _parse_ver(ver) File "setup.py", line 247, in _check_ver return getattr(operator, "__{}__".format(op))(pyver, wanted) File "/opt/salt/lib/python3.7/distutils/version.py", line 46, in __eq__ c = self._cmp(other) File "/opt/salt/lib/python3.7/distutils/version.py", line 337, in _cmp if self.version < other.version: TypeError: '<' not supported between instances of 'str' and 'int' ``` * Replace `saltstack.com` with `saltproject.io` on URLs being tested * Add back support to load old entrypoints by iterating instead of type checking Fixes #59961 * Fix issue #59975 * Fix pillar serialization for jinja #60083 * Fix test * Add changelog for #60083 * Update changelog and release for 3003.1 * Remove the changelog source refs * Add connect to IPCMessageSubscriber's async_methods Fixes #60049 by making sure an IPCMessageSubscriber that is wrapped by SyncWrapper has a connect method that runs the coroutine rather than returns a fugure. * Add changelog for #60049 * Update 60049.fixed * Fix coroutine spelling error Co-authored-by: Wayne Werner <waynejwerner@gmail.com> * IPC on windows cannot use socket paths Fixes #60298 * Update Jinja2 and lxml due to security related bugfix releases Jinja2 ------ CVE-2020-28493 moderate severity Vulnerable versions: < 2.11.3 Patched version: 2.11.3 This affects the package jinja2 from 0.0.0 and before 2.11.3. The ReDOS vulnerability of the regex is mainly due to the sub-pattern [a-zA-Z0-9.-]+.[a-zA-Z0-9.-]+ This issue can be mitigated by Markdown to format user content instead of the urlize filter, or by implementing request timeouts and limiting process memory. lxml ---- CVE-2021-28957 moderate severity Vulnerable versions: < 4.6.3 Patched version: 4.6.3 An XSS vulnerability was discovered in the python lxml clean module versions before 4.6.3. When disabling the safe_attrs_only and forms arguments, the Cleaner class does not remove the formaction attribute allowing for JS to bypass the sanitizer. A remote attacker could exploit this flaw to run arbitrary JS code on users who interact with incorrectly sanitized HTML. This issue is patched in lxml 4.6.3. * fix github actions jobs on branch until bullseye comes out * Upgrade to `six==1.16.0` to avoid problems on CI runs ``` 13:59:02 nox > Session invoke-pre-commit was successful. 13:59:02 nox > Running session invoke-pre-commit 13:59:02 nox > pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt 13:59:02 Collecting blessings==1.7 13:59:02 Using cached blessings-1.7-py3-none-any.whl (18 kB) 13:59:02 Collecting invoke==1.4.1 13:59:02 Using cached invoke-1.4.1-py3-none-any.whl (210 kB) 13:59:02 Collecting pyyaml==5.3.1 13:59:02 Using cached PyYAML-5.3.1.tar.gz (269 kB) 13:59:02 Collecting six==1.15.0 13:59:02 Using cached six-1.15.0-py2.py3-none-any.whl (10 kB) 13:59:02 Building wheels for collected packages: pyyaml 13:59:02 Building wheel for pyyaml (setup.py) ... - \ | / - \ | done 13:59:02 Created wheel for pyyaml: filename=PyYAML-5.3.1-cp37-cp37m-linux_x86_64.whl size=546391 sha256=e42e1d66cc32087f4d33ceb81268c86b59f1a97029b19459f91b8d6ad1430167 13:59:02 Stored in directory: /var/jenkins/.cache/pip/wheels/5e/03/1e/e1e954795d6f35dfc7b637fe2277bff021303bd9570ecea653 13:59:02 Successfully built pyyaml 13:59:02 Installing collected packages: six, pyyaml, invoke, blessings 13:59:02 Attempting uninstall: six 13:59:02 Found existing installation: six 1.16.0 13:59:02 Uninstalling six-1.16.0: 13:59:02 ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/var/jenkins/.cache/pre-commit/repomw8oee1s/py_env-python3/lib/python3.7/site-packages/__pycache__/six.cpython-37.pyc' 13:59:02 13:59:02 nox > Command pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt failed with exit code 1 13:59:02 nox > Session invoke-pre-commit failed. ``` * add changelog for https://github.com/saltstack/salt/issues/59982 * Regression test for #56273 * Fix race condition in batch. #56273 * Add changelog for #56273 * Update salt/client/__init__.py Co-authored-by: Pedro Algarvio <pedro@algarvio.me> * Update doc for salt/client * Update changelog/56273.fixed Thoreau said, "Simplify, Simplify" * Update docs * Update docs * Update CHANGELOG.md * Update 3003.1.rst * Ignore configuration for 'enable_fqdns_grains' for AIX, Solaris and Juniper * Added changelog * Let Mac OS Mojave run for 8 hours to avoid timeout * Remove FreeBSD-12.2 * Use Popen for VT * Still allow shell True * Drop shlex split * Add crypto re-init * Fix pre-commit * Do not call close in isalive * Skip tests not valid on windows * Cleanup things that are not really needed * We do not support irix * Fix pre-commit * Remove commented out lines * Add changelog for #60504 * Fix pre-commit issues * pyupgrade does not remove six imports * Fix OSErrors in some test cases * Remove un-needed args processing * Make state_running test more reliable * Removing tmpfs from Fedora 33. * Address leaks in fileserver caused by git backends At this time we do not have the ability to fix the upstream memory leaks in the gitfs backend providers. Work around their limitations by periodically restarting the file server update proccess. This will at least partially address #50313 * Remove un-used import * Fix warts caused by black version * Add changelog * We don't need two changelogs * Also pin the ``pip`` upgrade to be ``<21.2`` * Update the external ipaddress to the latest 3.9.5 version which has some security fixes. Updating the compat.p to use the vendored version if the python version is below 3.9.5 and only run the test_ipaddress.py tests if below 3.9.5. * Adding changelog * Requested changes. * Add shh_timeout to ssh_kwargs * move to with blocks * one with block * reight crypto * add back test file * add changelog * change log file number * add m2crypt support * only check m2crpto * Delete 60571.fixed * add back log * add newline * add newline for log file * Work around https://github.com/pypa/pip/pull/9450 See https://github.com/pypa/pip/issues/10212 * Drop six and Py2 * [3003.2] Add server alive (#60573) * add server alive * rename log * change default alive time * add requested changes * format string * reformat string again * run pre * customize * space * remove EOF dead space * fix pre-commit * run pre Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Changelog for 3003.2 * Man pages update for 3003.2 * Allow CVE entries in `changelog/` * Add security type for towncrier changelog * Add security type for changelog entries pre-commit check * Pin to ``pip>=20.2.4,<21.2`` Refs https://github.com/pypa/pip/pull/9450 * Drop six and Py2 * Fix bug introduced in https://github.com/saltstack/salt/pull/59648 Fixes #60046 * Add changelog * Fix doc builds * fix release notes about dropping ubuntu 16.04 * update file client * add changelog file * update changelog * Check permissions of minion config directory * Fix some wording in the messagebox and in comments * Add changelog * Fix extension for changelog * Add missing commas. It also worked, but now is better * docs_3003.3 * fixing version numbers in man pages. * removing newlines. * removing newlines. * Fixing release notes. * Fix changelog file for 3003.2 release * Fix test_state test using loader.context * Re-add test_context test * Allow Local System account, add timestamp * swaping the git-source for vsphere-automation-sdk-python * Remove destroy, handled in context manager Co-authored-by: Daniel Wozniak <dwozniak@saltstack.com> Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@wiked.org> Co-authored-by: Hoa-Long Tam <hoalong@apple.com> Co-authored-by: krionbsd <krion@freebsd.org> Co-authored-by: Elias Probst <e.probst@ssc-services.de> Co-authored-by: Daniel A. Wozniak <dwozniak@vmware.com> Co-authored-by: Frode Gundersen <frogunder@gmail.com> Co-authored-by: twangboy <slee@saltstack.com> Co-authored-by: twangboy <leesh@vmware.com> Co-authored-by: ScriptAutomate <derek@icanteven.io> Co-authored-by: Wayne Werner <waynejwerner@gmail.com> Co-authored-by: David Murphy < dmurphy@saltstack.com> Co-authored-by: Joe Eacott <jeacott@vmware.com> Co-authored-by: cmcmarrow <charles.mcmarrow.4@gmail.com> Co-authored-by: Twangboy <shane.d.lee@gmail.com>
2021-09-22 20:42:38 -04:00
):
if onedir and IS_LINUX:
session_run_always(session, "python3", "-m", "relenv", "toolchain", "fetch")
if not _upgrade_pip_setuptools_and_wheel(session):
Merge 3003.3 into master (#60924) * Merge 3002.6 bugfix changes (#59822) * Pass `CI_RUN` as an environment variable to the test run. This allows us to know if we're running the test suite under a CI environment or not and adapt/adjust if needed * Migrate `unit.setup` to PyTest * Backport ae36b15 just for test_install.py * Only skip tests on CI runs * Always store git sha in _version.py during installation * Fix PEP440 compliance. The wheel metadata version 1.2 states that the package version MUST be PEP440 compliant. This means that instead of `3002.2-511-g033c53eccb`, the salt version string should look like `3002.2+511.g033c53eccb`, a post release of `3002.2` ahead by 511 commits with the git sha `033c53eccb` * Fix and migrate `tests/unit/test_version.py` to PyTest * Skip test if `easy_install` is not available * We also need to be PEP440 compliant when there's no git history * Allow extra_filerefs as sanitized kwargs for SSH client * Fix regression on cmd.run when passing tuples as cmd Co-authored-by: Alexander Graul <agraul@suse.com> * Add unit tests to ensure cmd.run accepts tuples * Add unit test to check for extra_filerefs on SSH opts * Add changelog file * Fix comment for test case * Fix unit test to avoid failing on Windows * Skip failing test on windows * Fix test to work on Windows * Add all ssh kwargs to sanitize_kwargs method * Run pre-commit * Fix pylint * Fix cmdmod loglevel and module_names tests * Fix pre-commit * Skip ssh tests if binary does not exist * Use setup_loader for cmdmod test * Prevent argument injection in restartcheck * Add changelog for restartcheck fix * docs_3002.6 * Add back tests removed in merge Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> * Remove glance state module in favor of glance_image * update wording in changelog * bump deprecation warning to Silicon. * Updating warnutil version to Phosphorous. * Update salt/modules/keystone.py Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Check $HOMEBREW_PREFIX when linking against libcrypto When loading `libcrypto`, Salt checks for a Homebrew installation of `openssl` at Homebrew's default prefix of `/usr/local`. However, on Apple Silicon Macs, Homebrew's default installation prefix is `/opt/homebrew`. On all platforms, the prefix is configurable. If Salt doesn't find one of those `libcrypto`s, it will fall back on the un-versioned `/usr/lib/libcrypto.dylib`, which will cause the following crash: Application Specific Information: /usr/lib/libcrypto.dylib abort() called Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI. This commit checks $HOMEBREW_PREFIX instead of hard-coding `/usr/local`. * Add test case * Add changelog for 59808 * Add changelog entry * Make _find_libcrypto fail on Big Sur if it can't find a library Right now, if `_find_libcrypto` can't find any externally-managed versions of libcrypto, it will fall back on the pre-Catalina un-versioned system libcrypto. This does not exist on Big Sur and it would be better to raise an exception here rather than crashing later when trying to open it. * Update _find_libcrypto tests This commit simplifies the unit tests for _find_libcrypto by mocking out the host's filesystem and testing the common libcrypto installations (brew, ports, etc.) on Big Sur. It simplifies the tests for falling back on system versions of libcrypto on previous versions of macOS. * Fix description of test_find_libcrypto_with_system_before_catalina * Patch sys.platform for test_rsax931 tests * modules/match: add missing "minion_id" in Pillar example The documented Pillar example for `match.filter_by` lacks the `minion_id` parameter. Without it, the assignment won't work as expected. - fix documentation - add tests: - to prove the misbehavior of the documented example - to prove the proper behaviour when supplying `minion_id` - to ensure some misbehaviour observed with compound matchers doesn't occur * Fix for issue #59773 - When instantiating the loader grab values of grains and pillars if they are NamedLoaderContext instances. - The loader uses a copy of opts. - Impliment deepcopy on NamedLoaderContext instances. * Add changelog for #59773 * _get_initial_pillar function returns pillar * Fix linter issues * Clean up test * Bump deprecation release for neutron * Uncomment Sulfur release name * Removing the _ext_nodes deprecation warning and alias. * Adding changelog. * Renaming changelog file. * Update 59804.removed * Initial pass at fips_mode config option * Fix pre-commit * Fix tests and add changelog * update docs 3003 * update docs 3003 - newline * Fix warts in changelog * update releasenotes 3003 * add ubuntu-2004-amd64 m2crypto pycryptodome and tcp tests * add distro_arch * changing the cloud platforms file missed in 1a9b7be0e2f300d87924731dc5816fd1000cd22b * Update __utils__ calls to import utils in azure * Add changelog for 59744 * Fix azure unit tests and move to pytest * Use contextvars from site-packages for thin If a contextvars package exists one of the site-packages locations use it for the generated thin tarball. This overrides python's builtin contextvars and allows salt-ssh to work with python <=3.6 even when the master's python is >3.6 (Fixes #59942) * Add regression test for #59942 * Add changelog for #59942 * Update filemap to include test_py_versions * Fix broken thin tests * Always install the `contextvars` backport, even on Py3.7+ Without this change, salt-ssh cannot target systems with Python <= 3.6 * Use salt-factories to handle the container. Don't override default roster * Fix thin tests on windows * No need to use warn log level here * Fix getsitepackages for old virtualenv versions * Add explicit pyobjc reqs * Add back the passthrough stuff * Remove a line so pre-commit will run * Bugfix release docs * Bugfix release docs * Removing pip-compile log files * Bump requirements to address a few security issues * Address traceback on macOS ``` Traceback (most recent call last): File "setup.py", line 1448, in <module> setup(distclass=SaltDistribution) File "/Users/jenkins/setup-tests/.venv/lib/python3.7/site-packages/setuptools/__init__.py", line 153, in setup return distutils.core.setup(**attrs) File "/opt/salt/lib/python3.7/distutils/core.py", line 108, in setup _setup_distribution = dist = klass(attrs) File "setup.py", line 1068, in __init__ self.update_metadata() File "setup.py", line 1074, in update_metadata attrvalue = getattr(self, attrname, None) File "setup.py", line 1182, in _property_install_requires install_requires += _parse_requirements_file(reqfile) File "setup.py", line 270, in _parse_requirements_file platform.python_version(), _parse_op(op), _parse_ver(ver) File "setup.py", line 247, in _check_ver return getattr(operator, "__{}__".format(op))(pyver, wanted) File "/opt/salt/lib/python3.7/distutils/version.py", line 46, in __eq__ c = self._cmp(other) File "/opt/salt/lib/python3.7/distutils/version.py", line 337, in _cmp if self.version < other.version: TypeError: '<' not supported between instances of 'str' and 'int' ``` * Replace `saltstack.com` with `saltproject.io` on URLs being tested * Add back support to load old entrypoints by iterating instead of type checking Fixes #59961 * Fix issue #59975 * Fix pillar serialization for jinja #60083 * Fix test * Add changelog for #60083 * Update changelog and release for 3003.1 * Remove the changelog source refs * Add connect to IPCMessageSubscriber's async_methods Fixes #60049 by making sure an IPCMessageSubscriber that is wrapped by SyncWrapper has a connect method that runs the coroutine rather than returns a fugure. * Add changelog for #60049 * Update 60049.fixed * Fix coroutine spelling error Co-authored-by: Wayne Werner <waynejwerner@gmail.com> * IPC on windows cannot use socket paths Fixes #60298 * Update Jinja2 and lxml due to security related bugfix releases Jinja2 ------ CVE-2020-28493 moderate severity Vulnerable versions: < 2.11.3 Patched version: 2.11.3 This affects the package jinja2 from 0.0.0 and before 2.11.3. The ReDOS vulnerability of the regex is mainly due to the sub-pattern [a-zA-Z0-9.-]+.[a-zA-Z0-9.-]+ This issue can be mitigated by Markdown to format user content instead of the urlize filter, or by implementing request timeouts and limiting process memory. lxml ---- CVE-2021-28957 moderate severity Vulnerable versions: < 4.6.3 Patched version: 4.6.3 An XSS vulnerability was discovered in the python lxml clean module versions before 4.6.3. When disabling the safe_attrs_only and forms arguments, the Cleaner class does not remove the formaction attribute allowing for JS to bypass the sanitizer. A remote attacker could exploit this flaw to run arbitrary JS code on users who interact with incorrectly sanitized HTML. This issue is patched in lxml 4.6.3. * fix github actions jobs on branch until bullseye comes out * Upgrade to `six==1.16.0` to avoid problems on CI runs ``` 13:59:02 nox > Session invoke-pre-commit was successful. 13:59:02 nox > Running session invoke-pre-commit 13:59:02 nox > pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt 13:59:02 Collecting blessings==1.7 13:59:02 Using cached blessings-1.7-py3-none-any.whl (18 kB) 13:59:02 Collecting invoke==1.4.1 13:59:02 Using cached invoke-1.4.1-py3-none-any.whl (210 kB) 13:59:02 Collecting pyyaml==5.3.1 13:59:02 Using cached PyYAML-5.3.1.tar.gz (269 kB) 13:59:02 Collecting six==1.15.0 13:59:02 Using cached six-1.15.0-py2.py3-none-any.whl (10 kB) 13:59:02 Building wheels for collected packages: pyyaml 13:59:02 Building wheel for pyyaml (setup.py) ... - \ | / - \ | done 13:59:02 Created wheel for pyyaml: filename=PyYAML-5.3.1-cp37-cp37m-linux_x86_64.whl size=546391 sha256=e42e1d66cc32087f4d33ceb81268c86b59f1a97029b19459f91b8d6ad1430167 13:59:02 Stored in directory: /var/jenkins/.cache/pip/wheels/5e/03/1e/e1e954795d6f35dfc7b637fe2277bff021303bd9570ecea653 13:59:02 Successfully built pyyaml 13:59:02 Installing collected packages: six, pyyaml, invoke, blessings 13:59:02 Attempting uninstall: six 13:59:02 Found existing installation: six 1.16.0 13:59:02 Uninstalling six-1.16.0: 13:59:02 ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/var/jenkins/.cache/pre-commit/repomw8oee1s/py_env-python3/lib/python3.7/site-packages/__pycache__/six.cpython-37.pyc' 13:59:02 13:59:02 nox > Command pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt failed with exit code 1 13:59:02 nox > Session invoke-pre-commit failed. ``` * add changelog for https://github.com/saltstack/salt/issues/59982 * Regression test for #56273 * Fix race condition in batch. #56273 * Add changelog for #56273 * Update salt/client/__init__.py Co-authored-by: Pedro Algarvio <pedro@algarvio.me> * Update doc for salt/client * Update changelog/56273.fixed Thoreau said, "Simplify, Simplify" * Update docs * Update docs * Update CHANGELOG.md * Update 3003.1.rst * Ignore configuration for 'enable_fqdns_grains' for AIX, Solaris and Juniper * Added changelog * Let Mac OS Mojave run for 8 hours to avoid timeout * Remove FreeBSD-12.2 * Use Popen for VT * Still allow shell True * Drop shlex split * Add crypto re-init * Fix pre-commit * Do not call close in isalive * Skip tests not valid on windows * Cleanup things that are not really needed * We do not support irix * Fix pre-commit * Remove commented out lines * Add changelog for #60504 * Fix pre-commit issues * pyupgrade does not remove six imports * Fix OSErrors in some test cases * Remove un-needed args processing * Make state_running test more reliable * Removing tmpfs from Fedora 33. * Address leaks in fileserver caused by git backends At this time we do not have the ability to fix the upstream memory leaks in the gitfs backend providers. Work around their limitations by periodically restarting the file server update proccess. This will at least partially address #50313 * Remove un-used import * Fix warts caused by black version * Add changelog * We don't need two changelogs * Also pin the ``pip`` upgrade to be ``<21.2`` * Update the external ipaddress to the latest 3.9.5 version which has some security fixes. Updating the compat.p to use the vendored version if the python version is below 3.9.5 and only run the test_ipaddress.py tests if below 3.9.5. * Adding changelog * Requested changes. * Add shh_timeout to ssh_kwargs * move to with blocks * one with block * reight crypto * add back test file * add changelog * change log file number * add m2crypt support * only check m2crpto * Delete 60571.fixed * add back log * add newline * add newline for log file * Work around https://github.com/pypa/pip/pull/9450 See https://github.com/pypa/pip/issues/10212 * Drop six and Py2 * [3003.2] Add server alive (#60573) * add server alive * rename log * change default alive time * add requested changes * format string * reformat string again * run pre * customize * space * remove EOF dead space * fix pre-commit * run pre Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Changelog for 3003.2 * Man pages update for 3003.2 * Allow CVE entries in `changelog/` * Add security type for towncrier changelog * Add security type for changelog entries pre-commit check * Pin to ``pip>=20.2.4,<21.2`` Refs https://github.com/pypa/pip/pull/9450 * Drop six and Py2 * Fix bug introduced in https://github.com/saltstack/salt/pull/59648 Fixes #60046 * Add changelog * Fix doc builds * fix release notes about dropping ubuntu 16.04 * update file client * add changelog file * update changelog * Check permissions of minion config directory * Fix some wording in the messagebox and in comments * Add changelog * Fix extension for changelog * Add missing commas. It also worked, but now is better * docs_3003.3 * fixing version numbers in man pages. * removing newlines. * removing newlines. * Fixing release notes. * Fix changelog file for 3003.2 release * Fix test_state test using loader.context * Re-add test_context test * Allow Local System account, add timestamp * swaping the git-source for vsphere-automation-sdk-python * Remove destroy, handled in context manager Co-authored-by: Daniel Wozniak <dwozniak@saltstack.com> Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@wiked.org> Co-authored-by: Hoa-Long Tam <hoalong@apple.com> Co-authored-by: krionbsd <krion@freebsd.org> Co-authored-by: Elias Probst <e.probst@ssc-services.de> Co-authored-by: Daniel A. Wozniak <dwozniak@vmware.com> Co-authored-by: Frode Gundersen <frogunder@gmail.com> Co-authored-by: twangboy <slee@saltstack.com> Co-authored-by: twangboy <leesh@vmware.com> Co-authored-by: ScriptAutomate <derek@icanteven.io> Co-authored-by: Wayne Werner <waynejwerner@gmail.com> Co-authored-by: David Murphy < dmurphy@saltstack.com> Co-authored-by: Joe Eacott <jeacott@vmware.com> Co-authored-by: cmcmarrow <charles.mcmarrow.4@gmail.com> Co-authored-by: Twangboy <shane.d.lee@gmail.com>
2021-09-22 20:42:38 -04:00
return False
2019-10-07 18:29:02 +01:00
# Install requirements
env = os.environ.copy()
env["PIP_CONSTRAINT"] = str(REPO_ROOT / "requirements" / "constraints.txt")
requirements_file = _get_pip_requirements_file(
session, requirements_type=requirements_type
)
install_command = ["--progress-bar=off", "-r", requirements_file]
session.install(*install_command, silent=PIP_INSTALL_SILENT, env=env)
if extra_requirements:
install_command = ["--progress-bar=off"]
2019-10-07 18:29:02 +01:00
install_command += list(extra_requirements)
session.install(*install_command, silent=PIP_INSTALL_SILENT, env=env)
if EXTRA_REQUIREMENTS_INSTALL:
session.log(
2021-08-03 08:40:21 +01:00
"Installing the following extra requirements because the"
" EXTRA_REQUIREMENTS_INSTALL environment variable was set: %s",
EXTRA_REQUIREMENTS_INSTALL,
)
# We pass --constraint in this step because in case any of these extra dependencies has a requirement
# we're already using, we want to maintain the locked version
install_command = ["--progress-bar=off", "--constraint", requirements_file]
install_command += EXTRA_REQUIREMENTS_INSTALL.split()
session.install(*install_command, silent=PIP_INSTALL_SILENT, env=env)
Merge 3003.3 into master (#60924) * Merge 3002.6 bugfix changes (#59822) * Pass `CI_RUN` as an environment variable to the test run. This allows us to know if we're running the test suite under a CI environment or not and adapt/adjust if needed * Migrate `unit.setup` to PyTest * Backport ae36b15 just for test_install.py * Only skip tests on CI runs * Always store git sha in _version.py during installation * Fix PEP440 compliance. The wheel metadata version 1.2 states that the package version MUST be PEP440 compliant. This means that instead of `3002.2-511-g033c53eccb`, the salt version string should look like `3002.2+511.g033c53eccb`, a post release of `3002.2` ahead by 511 commits with the git sha `033c53eccb` * Fix and migrate `tests/unit/test_version.py` to PyTest * Skip test if `easy_install` is not available * We also need to be PEP440 compliant when there's no git history * Allow extra_filerefs as sanitized kwargs for SSH client * Fix regression on cmd.run when passing tuples as cmd Co-authored-by: Alexander Graul <agraul@suse.com> * Add unit tests to ensure cmd.run accepts tuples * Add unit test to check for extra_filerefs on SSH opts * Add changelog file * Fix comment for test case * Fix unit test to avoid failing on Windows * Skip failing test on windows * Fix test to work on Windows * Add all ssh kwargs to sanitize_kwargs method * Run pre-commit * Fix pylint * Fix cmdmod loglevel and module_names tests * Fix pre-commit * Skip ssh tests if binary does not exist * Use setup_loader for cmdmod test * Prevent argument injection in restartcheck * Add changelog for restartcheck fix * docs_3002.6 * Add back tests removed in merge Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> * Remove glance state module in favor of glance_image * update wording in changelog * bump deprecation warning to Silicon. * Updating warnutil version to Phosphorous. * Update salt/modules/keystone.py Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Check $HOMEBREW_PREFIX when linking against libcrypto When loading `libcrypto`, Salt checks for a Homebrew installation of `openssl` at Homebrew's default prefix of `/usr/local`. However, on Apple Silicon Macs, Homebrew's default installation prefix is `/opt/homebrew`. On all platforms, the prefix is configurable. If Salt doesn't find one of those `libcrypto`s, it will fall back on the un-versioned `/usr/lib/libcrypto.dylib`, which will cause the following crash: Application Specific Information: /usr/lib/libcrypto.dylib abort() called Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI. This commit checks $HOMEBREW_PREFIX instead of hard-coding `/usr/local`. * Add test case * Add changelog for 59808 * Add changelog entry * Make _find_libcrypto fail on Big Sur if it can't find a library Right now, if `_find_libcrypto` can't find any externally-managed versions of libcrypto, it will fall back on the pre-Catalina un-versioned system libcrypto. This does not exist on Big Sur and it would be better to raise an exception here rather than crashing later when trying to open it. * Update _find_libcrypto tests This commit simplifies the unit tests for _find_libcrypto by mocking out the host's filesystem and testing the common libcrypto installations (brew, ports, etc.) on Big Sur. It simplifies the tests for falling back on system versions of libcrypto on previous versions of macOS. * Fix description of test_find_libcrypto_with_system_before_catalina * Patch sys.platform for test_rsax931 tests * modules/match: add missing "minion_id" in Pillar example The documented Pillar example for `match.filter_by` lacks the `minion_id` parameter. Without it, the assignment won't work as expected. - fix documentation - add tests: - to prove the misbehavior of the documented example - to prove the proper behaviour when supplying `minion_id` - to ensure some misbehaviour observed with compound matchers doesn't occur * Fix for issue #59773 - When instantiating the loader grab values of grains and pillars if they are NamedLoaderContext instances. - The loader uses a copy of opts. - Impliment deepcopy on NamedLoaderContext instances. * Add changelog for #59773 * _get_initial_pillar function returns pillar * Fix linter issues * Clean up test * Bump deprecation release for neutron * Uncomment Sulfur release name * Removing the _ext_nodes deprecation warning and alias. * Adding changelog. * Renaming changelog file. * Update 59804.removed * Initial pass at fips_mode config option * Fix pre-commit * Fix tests and add changelog * update docs 3003 * update docs 3003 - newline * Fix warts in changelog * update releasenotes 3003 * add ubuntu-2004-amd64 m2crypto pycryptodome and tcp tests * add distro_arch * changing the cloud platforms file missed in 1a9b7be0e2f300d87924731dc5816fd1000cd22b * Update __utils__ calls to import utils in azure * Add changelog for 59744 * Fix azure unit tests and move to pytest * Use contextvars from site-packages for thin If a contextvars package exists one of the site-packages locations use it for the generated thin tarball. This overrides python's builtin contextvars and allows salt-ssh to work with python <=3.6 even when the master's python is >3.6 (Fixes #59942) * Add regression test for #59942 * Add changelog for #59942 * Update filemap to include test_py_versions * Fix broken thin tests * Always install the `contextvars` backport, even on Py3.7+ Without this change, salt-ssh cannot target systems with Python <= 3.6 * Use salt-factories to handle the container. Don't override default roster * Fix thin tests on windows * No need to use warn log level here * Fix getsitepackages for old virtualenv versions * Add explicit pyobjc reqs * Add back the passthrough stuff * Remove a line so pre-commit will run * Bugfix release docs * Bugfix release docs * Removing pip-compile log files * Bump requirements to address a few security issues * Address traceback on macOS ``` Traceback (most recent call last): File "setup.py", line 1448, in <module> setup(distclass=SaltDistribution) File "/Users/jenkins/setup-tests/.venv/lib/python3.7/site-packages/setuptools/__init__.py", line 153, in setup return distutils.core.setup(**attrs) File "/opt/salt/lib/python3.7/distutils/core.py", line 108, in setup _setup_distribution = dist = klass(attrs) File "setup.py", line 1068, in __init__ self.update_metadata() File "setup.py", line 1074, in update_metadata attrvalue = getattr(self, attrname, None) File "setup.py", line 1182, in _property_install_requires install_requires += _parse_requirements_file(reqfile) File "setup.py", line 270, in _parse_requirements_file platform.python_version(), _parse_op(op), _parse_ver(ver) File "setup.py", line 247, in _check_ver return getattr(operator, "__{}__".format(op))(pyver, wanted) File "/opt/salt/lib/python3.7/distutils/version.py", line 46, in __eq__ c = self._cmp(other) File "/opt/salt/lib/python3.7/distutils/version.py", line 337, in _cmp if self.version < other.version: TypeError: '<' not supported between instances of 'str' and 'int' ``` * Replace `saltstack.com` with `saltproject.io` on URLs being tested * Add back support to load old entrypoints by iterating instead of type checking Fixes #59961 * Fix issue #59975 * Fix pillar serialization for jinja #60083 * Fix test * Add changelog for #60083 * Update changelog and release for 3003.1 * Remove the changelog source refs * Add connect to IPCMessageSubscriber's async_methods Fixes #60049 by making sure an IPCMessageSubscriber that is wrapped by SyncWrapper has a connect method that runs the coroutine rather than returns a fugure. * Add changelog for #60049 * Update 60049.fixed * Fix coroutine spelling error Co-authored-by: Wayne Werner <waynejwerner@gmail.com> * IPC on windows cannot use socket paths Fixes #60298 * Update Jinja2 and lxml due to security related bugfix releases Jinja2 ------ CVE-2020-28493 moderate severity Vulnerable versions: < 2.11.3 Patched version: 2.11.3 This affects the package jinja2 from 0.0.0 and before 2.11.3. The ReDOS vulnerability of the regex is mainly due to the sub-pattern [a-zA-Z0-9.-]+.[a-zA-Z0-9.-]+ This issue can be mitigated by Markdown to format user content instead of the urlize filter, or by implementing request timeouts and limiting process memory. lxml ---- CVE-2021-28957 moderate severity Vulnerable versions: < 4.6.3 Patched version: 4.6.3 An XSS vulnerability was discovered in the python lxml clean module versions before 4.6.3. When disabling the safe_attrs_only and forms arguments, the Cleaner class does not remove the formaction attribute allowing for JS to bypass the sanitizer. A remote attacker could exploit this flaw to run arbitrary JS code on users who interact with incorrectly sanitized HTML. This issue is patched in lxml 4.6.3. * fix github actions jobs on branch until bullseye comes out * Upgrade to `six==1.16.0` to avoid problems on CI runs ``` 13:59:02 nox > Session invoke-pre-commit was successful. 13:59:02 nox > Running session invoke-pre-commit 13:59:02 nox > pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt 13:59:02 Collecting blessings==1.7 13:59:02 Using cached blessings-1.7-py3-none-any.whl (18 kB) 13:59:02 Collecting invoke==1.4.1 13:59:02 Using cached invoke-1.4.1-py3-none-any.whl (210 kB) 13:59:02 Collecting pyyaml==5.3.1 13:59:02 Using cached PyYAML-5.3.1.tar.gz (269 kB) 13:59:02 Collecting six==1.15.0 13:59:02 Using cached six-1.15.0-py2.py3-none-any.whl (10 kB) 13:59:02 Building wheels for collected packages: pyyaml 13:59:02 Building wheel for pyyaml (setup.py) ... - \ | / - \ | done 13:59:02 Created wheel for pyyaml: filename=PyYAML-5.3.1-cp37-cp37m-linux_x86_64.whl size=546391 sha256=e42e1d66cc32087f4d33ceb81268c86b59f1a97029b19459f91b8d6ad1430167 13:59:02 Stored in directory: /var/jenkins/.cache/pip/wheels/5e/03/1e/e1e954795d6f35dfc7b637fe2277bff021303bd9570ecea653 13:59:02 Successfully built pyyaml 13:59:02 Installing collected packages: six, pyyaml, invoke, blessings 13:59:02 Attempting uninstall: six 13:59:02 Found existing installation: six 1.16.0 13:59:02 Uninstalling six-1.16.0: 13:59:02 ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/var/jenkins/.cache/pre-commit/repomw8oee1s/py_env-python3/lib/python3.7/site-packages/__pycache__/six.cpython-37.pyc' 13:59:02 13:59:02 nox > Command pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt failed with exit code 1 13:59:02 nox > Session invoke-pre-commit failed. ``` * add changelog for https://github.com/saltstack/salt/issues/59982 * Regression test for #56273 * Fix race condition in batch. #56273 * Add changelog for #56273 * Update salt/client/__init__.py Co-authored-by: Pedro Algarvio <pedro@algarvio.me> * Update doc for salt/client * Update changelog/56273.fixed Thoreau said, "Simplify, Simplify" * Update docs * Update docs * Update CHANGELOG.md * Update 3003.1.rst * Ignore configuration for 'enable_fqdns_grains' for AIX, Solaris and Juniper * Added changelog * Let Mac OS Mojave run for 8 hours to avoid timeout * Remove FreeBSD-12.2 * Use Popen for VT * Still allow shell True * Drop shlex split * Add crypto re-init * Fix pre-commit * Do not call close in isalive * Skip tests not valid on windows * Cleanup things that are not really needed * We do not support irix * Fix pre-commit * Remove commented out lines * Add changelog for #60504 * Fix pre-commit issues * pyupgrade does not remove six imports * Fix OSErrors in some test cases * Remove un-needed args processing * Make state_running test more reliable * Removing tmpfs from Fedora 33. * Address leaks in fileserver caused by git backends At this time we do not have the ability to fix the upstream memory leaks in the gitfs backend providers. Work around their limitations by periodically restarting the file server update proccess. This will at least partially address #50313 * Remove un-used import * Fix warts caused by black version * Add changelog * We don't need two changelogs * Also pin the ``pip`` upgrade to be ``<21.2`` * Update the external ipaddress to the latest 3.9.5 version which has some security fixes. Updating the compat.p to use the vendored version if the python version is below 3.9.5 and only run the test_ipaddress.py tests if below 3.9.5. * Adding changelog * Requested changes. * Add shh_timeout to ssh_kwargs * move to with blocks * one with block * reight crypto * add back test file * add changelog * change log file number * add m2crypt support * only check m2crpto * Delete 60571.fixed * add back log * add newline * add newline for log file * Work around https://github.com/pypa/pip/pull/9450 See https://github.com/pypa/pip/issues/10212 * Drop six and Py2 * [3003.2] Add server alive (#60573) * add server alive * rename log * change default alive time * add requested changes * format string * reformat string again * run pre * customize * space * remove EOF dead space * fix pre-commit * run pre Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Changelog for 3003.2 * Man pages update for 3003.2 * Allow CVE entries in `changelog/` * Add security type for towncrier changelog * Add security type for changelog entries pre-commit check * Pin to ``pip>=20.2.4,<21.2`` Refs https://github.com/pypa/pip/pull/9450 * Drop six and Py2 * Fix bug introduced in https://github.com/saltstack/salt/pull/59648 Fixes #60046 * Add changelog * Fix doc builds * fix release notes about dropping ubuntu 16.04 * update file client * add changelog file * update changelog * Check permissions of minion config directory * Fix some wording in the messagebox and in comments * Add changelog * Fix extension for changelog * Add missing commas. It also worked, but now is better * docs_3003.3 * fixing version numbers in man pages. * removing newlines. * removing newlines. * Fixing release notes. * Fix changelog file for 3003.2 release * Fix test_state test using loader.context * Re-add test_context test * Allow Local System account, add timestamp * swaping the git-source for vsphere-automation-sdk-python * Remove destroy, handled in context manager Co-authored-by: Daniel Wozniak <dwozniak@saltstack.com> Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@wiked.org> Co-authored-by: Hoa-Long Tam <hoalong@apple.com> Co-authored-by: krionbsd <krion@freebsd.org> Co-authored-by: Elias Probst <e.probst@ssc-services.de> Co-authored-by: Daniel A. Wozniak <dwozniak@vmware.com> Co-authored-by: Frode Gundersen <frogunder@gmail.com> Co-authored-by: twangboy <slee@saltstack.com> Co-authored-by: twangboy <leesh@vmware.com> Co-authored-by: ScriptAutomate <derek@icanteven.io> Co-authored-by: Wayne Werner <waynejwerner@gmail.com> Co-authored-by: David Murphy < dmurphy@saltstack.com> Co-authored-by: Joe Eacott <jeacott@vmware.com> Co-authored-by: cmcmarrow <charles.mcmarrow.4@gmail.com> Co-authored-by: Twangboy <shane.d.lee@gmail.com>
2021-09-22 20:42:38 -04:00
return True
def _install_coverage_requirement(session):
if SKIP_REQUIREMENTS_INSTALL is False:
env = os.environ.copy()
env["PIP_CONSTRAINT"] = str(REPO_ROOT / "requirements" / "constraints.txt")
coverage_requirement = COVERAGE_REQUIREMENT
if coverage_requirement is None:
coverage_requirement = "coverage==7.3.1"
if IS_LINUX:
distro_slug = os.environ.get("TOOLS_DISTRO_SLUG")
if distro_slug is not None and distro_slug in (
"centos-7",
"debian-10",
"photonos-3",
):
# Keep the old coverage requirement version since the new one, on these
2023-12-19 16:13:09 +01:00
# Plaforms turns the test suite quite slow.
# Unit tests don't finish before the 5 hours timeout when they should
# finish within 1 to 2 hours.
coverage_requirement = "coverage==5.5"
session.install(
"--progress-bar=off",
coverage_requirement,
silent=PIP_INSTALL_SILENT,
env=env,
)
def _run_with_coverage(session, *test_cmd, env=None, on_rerun=False):
_install_coverage_requirement(session)
if on_rerun is False:
session.run("coverage", "erase")
if env is None:
env = {}
sitecustomize_dir = session.run(
"salt-factories", "--coverage", silent=True, log=True, stderr=None
)
if sitecustomize_dir is not None:
sitecustomize_dir = pathlib.Path(sitecustomize_dir.strip()).resolve()
if not sitecustomize_dir.exists():
session.error(
f"The path to 'sitecustomize.py', '{str(sitecustomize_dir)}', does not exist."
)
if sitecustomize_dir:
try:
relative_sitecustomize_dir = sitecustomize_dir.relative_to(REPO_ROOT)
except ValueError:
relative_sitecustomize_dir = sitecustomize_dir
log_msg = f"Discovered salt-factories coverage 'sitecustomize.py' path: {relative_sitecustomize_dir}"
try:
session.debug(log_msg)
except AttributeError:
# Older nox
session.log(log_msg)
python_path_env_var = os.environ.get("PYTHONPATH") or None
if python_path_env_var is None:
python_path_env_var = str(sitecustomize_dir)
else:
python_path_entries = python_path_env_var.split(os.pathsep)
if str(sitecustomize_dir) in python_path_entries:
python_path_entries.remove(str(sitecustomize_dir))
python_path_entries.insert(0, str(sitecustomize_dir))
python_path_env_var = os.pathsep.join(python_path_entries)
env.update(
{
# The updated python path so that sitecustomize is importable
"PYTHONPATH": python_path_env_var,
# Instruct sub processes to also run under coverage
"COVERAGE_PROCESS_START": str(REPO_ROOT / ".coveragerc"),
# The full path to the .coverage data file. Makes sure we always write
# them to the same directory
"COVERAGE_FILE": COVERAGE_FILE,
}
)
session.run(*test_cmd, env=env)
def _report_coverage(
session,
combine=True,
cli_report=True,
html_report=False,
xml_report=False,
json_report=False,
):
_install_coverage_requirement(session)
if not any([combine, cli_report, html_report, xml_report, json_report]):
session.error(
"At least one of combine, cli_report, html_report, xml_report, json_report needs to be True"
)
env = {
# The full path to the .coverage data file. Makes sure we always write
# them to the same directory
"COVERAGE_FILE": COVERAGE_FILE,
}
report_section = None
if session.posargs:
report_section = session.posargs.pop(0)
if report_section not in ("salt", "tests"):
session.error(
f"The report section can only be one of 'salt', 'tests', not: {report_section}"
)
if session.posargs:
session.error(
"Only one argument can be passed to the session, which is optional "
"and is one of 'salt', 'tests'."
)
if combine is True:
coverage_db_files = glob.glob(f"{COVERAGE_FILE}.*")
if coverage_db_files:
with contextlib.suppress(CommandFailed):
# Sometimes some of the coverage files are corrupt which would trigger a CommandFailed
# exception
session.run("coverage", "combine", env=env)
elif os.path.exists(COVERAGE_FILE):
session_warn(session, "Coverage files already combined.")
if os.path.exists(COVERAGE_FILE) and not IS_WINDOWS:
# Some coverage files might have come from a windows machine, fix paths
with sqlite3.connect(COVERAGE_FILE) as db:
res = db.execute(r"SELECT * FROM file WHERE path LIKE '%salt\%'")
if res.fetchone():
session_warn(
session,
"Replacing backwards slashes with forward slashes on file "
"paths in the coverage database",
)
db.execute(
r"UPDATE OR IGNORE file SET path=replace(path, '\', '/');"
)
if not os.path.exists(COVERAGE_FILE):
session.error("No coverage files found.")
if report_section == "salt":
json_coverage_file = COVERAGE_OUTPUT_DIR.relative_to(REPO_ROOT) / "salt.json"
xml_coverage_file = COVERAGE_OUTPUT_DIR.relative_to(REPO_ROOT) / "salt.xml"
html_coverage_dir = COVERAGE_OUTPUT_DIR.relative_to(REPO_ROOT) / "html" / "salt"
cmd_args = [
"--omit=tests/*,tests/pytests/pkg/*",
"--include=salt/*",
]
elif report_section == "tests":
json_coverage_file = COVERAGE_OUTPUT_DIR.relative_to(REPO_ROOT) / "tests.json"
xml_coverage_file = COVERAGE_OUTPUT_DIR.relative_to(REPO_ROOT) / "tests.xml"
html_coverage_dir = (
COVERAGE_OUTPUT_DIR.relative_to(REPO_ROOT) / "html" / "tests"
)
cmd_args = [
"--omit=salt/*",
"--include=tests/*,tests/pytests/pkg/*",
]
else:
json_coverage_file = (
COVERAGE_OUTPUT_DIR.relative_to(REPO_ROOT) / "coverage.json"
)
xml_coverage_file = COVERAGE_OUTPUT_DIR.relative_to(REPO_ROOT) / "coverage.xml"
html_coverage_dir = COVERAGE_OUTPUT_DIR.relative_to(REPO_ROOT) / "html" / "full"
cmd_args = [
"--include=salt/*,tests/*,tests/pytests/pkg/*",
]
if cli_report:
session.run(
"coverage",
"report",
"--precision=2",
*cmd_args,
env=env,
)
if html_report:
session.run(
"coverage",
"html",
"-d",
str(html_coverage_dir),
"--show-contexts",
"--precision=2",
*cmd_args,
env=env,
)
if xml_report:
try:
session.run(
"coverage",
"xml",
"-o",
str(xml_coverage_file),
*cmd_args,
env=env,
)
except CommandFailed:
session_warn(
session, "Failed to generate the source XML code coverage report"
)
if json_report:
session.run(
"coverage",
"json",
"-o",
str(json_coverage_file),
"--show-contexts",
*cmd_args,
env=env,
)
@nox.session(python=_PYTHON_VERSIONS, name="test-parametrized")
@nox.parametrize("coverage", [False, True])
2019-10-07 17:56:46 +01:00
@nox.parametrize("transport", ["zeromq", "tcp"])
@nox.parametrize("crypto", [None, "m2crypto", "pycryptodome"])
def test_parametrized(session, coverage, transport, crypto):
"""
DO NOT CALL THIS NOX SESSION DIRECTLY
"""
# Install requirements
if _install_requirements(session):
Merge 3003.3 into master (#60924) * Merge 3002.6 bugfix changes (#59822) * Pass `CI_RUN` as an environment variable to the test run. This allows us to know if we're running the test suite under a CI environment or not and adapt/adjust if needed * Migrate `unit.setup` to PyTest * Backport ae36b15 just for test_install.py * Only skip tests on CI runs * Always store git sha in _version.py during installation * Fix PEP440 compliance. The wheel metadata version 1.2 states that the package version MUST be PEP440 compliant. This means that instead of `3002.2-511-g033c53eccb`, the salt version string should look like `3002.2+511.g033c53eccb`, a post release of `3002.2` ahead by 511 commits with the git sha `033c53eccb` * Fix and migrate `tests/unit/test_version.py` to PyTest * Skip test if `easy_install` is not available * We also need to be PEP440 compliant when there's no git history * Allow extra_filerefs as sanitized kwargs for SSH client * Fix regression on cmd.run when passing tuples as cmd Co-authored-by: Alexander Graul <agraul@suse.com> * Add unit tests to ensure cmd.run accepts tuples * Add unit test to check for extra_filerefs on SSH opts * Add changelog file * Fix comment for test case * Fix unit test to avoid failing on Windows * Skip failing test on windows * Fix test to work on Windows * Add all ssh kwargs to sanitize_kwargs method * Run pre-commit * Fix pylint * Fix cmdmod loglevel and module_names tests * Fix pre-commit * Skip ssh tests if binary does not exist * Use setup_loader for cmdmod test * Prevent argument injection in restartcheck * Add changelog for restartcheck fix * docs_3002.6 * Add back tests removed in merge Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> * Remove glance state module in favor of glance_image * update wording in changelog * bump deprecation warning to Silicon. * Updating warnutil version to Phosphorous. * Update salt/modules/keystone.py Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Check $HOMEBREW_PREFIX when linking against libcrypto When loading `libcrypto`, Salt checks for a Homebrew installation of `openssl` at Homebrew's default prefix of `/usr/local`. However, on Apple Silicon Macs, Homebrew's default installation prefix is `/opt/homebrew`. On all platforms, the prefix is configurable. If Salt doesn't find one of those `libcrypto`s, it will fall back on the un-versioned `/usr/lib/libcrypto.dylib`, which will cause the following crash: Application Specific Information: /usr/lib/libcrypto.dylib abort() called Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI. This commit checks $HOMEBREW_PREFIX instead of hard-coding `/usr/local`. * Add test case * Add changelog for 59808 * Add changelog entry * Make _find_libcrypto fail on Big Sur if it can't find a library Right now, if `_find_libcrypto` can't find any externally-managed versions of libcrypto, it will fall back on the pre-Catalina un-versioned system libcrypto. This does not exist on Big Sur and it would be better to raise an exception here rather than crashing later when trying to open it. * Update _find_libcrypto tests This commit simplifies the unit tests for _find_libcrypto by mocking out the host's filesystem and testing the common libcrypto installations (brew, ports, etc.) on Big Sur. It simplifies the tests for falling back on system versions of libcrypto on previous versions of macOS. * Fix description of test_find_libcrypto_with_system_before_catalina * Patch sys.platform for test_rsax931 tests * modules/match: add missing "minion_id" in Pillar example The documented Pillar example for `match.filter_by` lacks the `minion_id` parameter. Without it, the assignment won't work as expected. - fix documentation - add tests: - to prove the misbehavior of the documented example - to prove the proper behaviour when supplying `minion_id` - to ensure some misbehaviour observed with compound matchers doesn't occur * Fix for issue #59773 - When instantiating the loader grab values of grains and pillars if they are NamedLoaderContext instances. - The loader uses a copy of opts. - Impliment deepcopy on NamedLoaderContext instances. * Add changelog for #59773 * _get_initial_pillar function returns pillar * Fix linter issues * Clean up test * Bump deprecation release for neutron * Uncomment Sulfur release name * Removing the _ext_nodes deprecation warning and alias. * Adding changelog. * Renaming changelog file. * Update 59804.removed * Initial pass at fips_mode config option * Fix pre-commit * Fix tests and add changelog * update docs 3003 * update docs 3003 - newline * Fix warts in changelog * update releasenotes 3003 * add ubuntu-2004-amd64 m2crypto pycryptodome and tcp tests * add distro_arch * changing the cloud platforms file missed in 1a9b7be0e2f300d87924731dc5816fd1000cd22b * Update __utils__ calls to import utils in azure * Add changelog for 59744 * Fix azure unit tests and move to pytest * Use contextvars from site-packages for thin If a contextvars package exists one of the site-packages locations use it for the generated thin tarball. This overrides python's builtin contextvars and allows salt-ssh to work with python <=3.6 even when the master's python is >3.6 (Fixes #59942) * Add regression test for #59942 * Add changelog for #59942 * Update filemap to include test_py_versions * Fix broken thin tests * Always install the `contextvars` backport, even on Py3.7+ Without this change, salt-ssh cannot target systems with Python <= 3.6 * Use salt-factories to handle the container. Don't override default roster * Fix thin tests on windows * No need to use warn log level here * Fix getsitepackages for old virtualenv versions * Add explicit pyobjc reqs * Add back the passthrough stuff * Remove a line so pre-commit will run * Bugfix release docs * Bugfix release docs * Removing pip-compile log files * Bump requirements to address a few security issues * Address traceback on macOS ``` Traceback (most recent call last): File "setup.py", line 1448, in <module> setup(distclass=SaltDistribution) File "/Users/jenkins/setup-tests/.venv/lib/python3.7/site-packages/setuptools/__init__.py", line 153, in setup return distutils.core.setup(**attrs) File "/opt/salt/lib/python3.7/distutils/core.py", line 108, in setup _setup_distribution = dist = klass(attrs) File "setup.py", line 1068, in __init__ self.update_metadata() File "setup.py", line 1074, in update_metadata attrvalue = getattr(self, attrname, None) File "setup.py", line 1182, in _property_install_requires install_requires += _parse_requirements_file(reqfile) File "setup.py", line 270, in _parse_requirements_file platform.python_version(), _parse_op(op), _parse_ver(ver) File "setup.py", line 247, in _check_ver return getattr(operator, "__{}__".format(op))(pyver, wanted) File "/opt/salt/lib/python3.7/distutils/version.py", line 46, in __eq__ c = self._cmp(other) File "/opt/salt/lib/python3.7/distutils/version.py", line 337, in _cmp if self.version < other.version: TypeError: '<' not supported between instances of 'str' and 'int' ``` * Replace `saltstack.com` with `saltproject.io` on URLs being tested * Add back support to load old entrypoints by iterating instead of type checking Fixes #59961 * Fix issue #59975 * Fix pillar serialization for jinja #60083 * Fix test * Add changelog for #60083 * Update changelog and release for 3003.1 * Remove the changelog source refs * Add connect to IPCMessageSubscriber's async_methods Fixes #60049 by making sure an IPCMessageSubscriber that is wrapped by SyncWrapper has a connect method that runs the coroutine rather than returns a fugure. * Add changelog for #60049 * Update 60049.fixed * Fix coroutine spelling error Co-authored-by: Wayne Werner <waynejwerner@gmail.com> * IPC on windows cannot use socket paths Fixes #60298 * Update Jinja2 and lxml due to security related bugfix releases Jinja2 ------ CVE-2020-28493 moderate severity Vulnerable versions: < 2.11.3 Patched version: 2.11.3 This affects the package jinja2 from 0.0.0 and before 2.11.3. The ReDOS vulnerability of the regex is mainly due to the sub-pattern [a-zA-Z0-9.-]+.[a-zA-Z0-9.-]+ This issue can be mitigated by Markdown to format user content instead of the urlize filter, or by implementing request timeouts and limiting process memory. lxml ---- CVE-2021-28957 moderate severity Vulnerable versions: < 4.6.3 Patched version: 4.6.3 An XSS vulnerability was discovered in the python lxml clean module versions before 4.6.3. When disabling the safe_attrs_only and forms arguments, the Cleaner class does not remove the formaction attribute allowing for JS to bypass the sanitizer. A remote attacker could exploit this flaw to run arbitrary JS code on users who interact with incorrectly sanitized HTML. This issue is patched in lxml 4.6.3. * fix github actions jobs on branch until bullseye comes out * Upgrade to `six==1.16.0` to avoid problems on CI runs ``` 13:59:02 nox > Session invoke-pre-commit was successful. 13:59:02 nox > Running session invoke-pre-commit 13:59:02 nox > pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt 13:59:02 Collecting blessings==1.7 13:59:02 Using cached blessings-1.7-py3-none-any.whl (18 kB) 13:59:02 Collecting invoke==1.4.1 13:59:02 Using cached invoke-1.4.1-py3-none-any.whl (210 kB) 13:59:02 Collecting pyyaml==5.3.1 13:59:02 Using cached PyYAML-5.3.1.tar.gz (269 kB) 13:59:02 Collecting six==1.15.0 13:59:02 Using cached six-1.15.0-py2.py3-none-any.whl (10 kB) 13:59:02 Building wheels for collected packages: pyyaml 13:59:02 Building wheel for pyyaml (setup.py) ... - \ | / - \ | done 13:59:02 Created wheel for pyyaml: filename=PyYAML-5.3.1-cp37-cp37m-linux_x86_64.whl size=546391 sha256=e42e1d66cc32087f4d33ceb81268c86b59f1a97029b19459f91b8d6ad1430167 13:59:02 Stored in directory: /var/jenkins/.cache/pip/wheels/5e/03/1e/e1e954795d6f35dfc7b637fe2277bff021303bd9570ecea653 13:59:02 Successfully built pyyaml 13:59:02 Installing collected packages: six, pyyaml, invoke, blessings 13:59:02 Attempting uninstall: six 13:59:02 Found existing installation: six 1.16.0 13:59:02 Uninstalling six-1.16.0: 13:59:02 ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/var/jenkins/.cache/pre-commit/repomw8oee1s/py_env-python3/lib/python3.7/site-packages/__pycache__/six.cpython-37.pyc' 13:59:02 13:59:02 nox > Command pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt failed with exit code 1 13:59:02 nox > Session invoke-pre-commit failed. ``` * add changelog for https://github.com/saltstack/salt/issues/59982 * Regression test for #56273 * Fix race condition in batch. #56273 * Add changelog for #56273 * Update salt/client/__init__.py Co-authored-by: Pedro Algarvio <pedro@algarvio.me> * Update doc for salt/client * Update changelog/56273.fixed Thoreau said, "Simplify, Simplify" * Update docs * Update docs * Update CHANGELOG.md * Update 3003.1.rst * Ignore configuration for 'enable_fqdns_grains' for AIX, Solaris and Juniper * Added changelog * Let Mac OS Mojave run for 8 hours to avoid timeout * Remove FreeBSD-12.2 * Use Popen for VT * Still allow shell True * Drop shlex split * Add crypto re-init * Fix pre-commit * Do not call close in isalive * Skip tests not valid on windows * Cleanup things that are not really needed * We do not support irix * Fix pre-commit * Remove commented out lines * Add changelog for #60504 * Fix pre-commit issues * pyupgrade does not remove six imports * Fix OSErrors in some test cases * Remove un-needed args processing * Make state_running test more reliable * Removing tmpfs from Fedora 33. * Address leaks in fileserver caused by git backends At this time we do not have the ability to fix the upstream memory leaks in the gitfs backend providers. Work around their limitations by periodically restarting the file server update proccess. This will at least partially address #50313 * Remove un-used import * Fix warts caused by black version * Add changelog * We don't need two changelogs * Also pin the ``pip`` upgrade to be ``<21.2`` * Update the external ipaddress to the latest 3.9.5 version which has some security fixes. Updating the compat.p to use the vendored version if the python version is below 3.9.5 and only run the test_ipaddress.py tests if below 3.9.5. * Adding changelog * Requested changes. * Add shh_timeout to ssh_kwargs * move to with blocks * one with block * reight crypto * add back test file * add changelog * change log file number * add m2crypt support * only check m2crpto * Delete 60571.fixed * add back log * add newline * add newline for log file * Work around https://github.com/pypa/pip/pull/9450 See https://github.com/pypa/pip/issues/10212 * Drop six and Py2 * [3003.2] Add server alive (#60573) * add server alive * rename log * change default alive time * add requested changes * format string * reformat string again * run pre * customize * space * remove EOF dead space * fix pre-commit * run pre Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Changelog for 3003.2 * Man pages update for 3003.2 * Allow CVE entries in `changelog/` * Add security type for towncrier changelog * Add security type for changelog entries pre-commit check * Pin to ``pip>=20.2.4,<21.2`` Refs https://github.com/pypa/pip/pull/9450 * Drop six and Py2 * Fix bug introduced in https://github.com/saltstack/salt/pull/59648 Fixes #60046 * Add changelog * Fix doc builds * fix release notes about dropping ubuntu 16.04 * update file client * add changelog file * update changelog * Check permissions of minion config directory * Fix some wording in the messagebox and in comments * Add changelog * Fix extension for changelog * Add missing commas. It also worked, but now is better * docs_3003.3 * fixing version numbers in man pages. * removing newlines. * removing newlines. * Fixing release notes. * Fix changelog file for 3003.2 release * Fix test_state test using loader.context * Re-add test_context test * Allow Local System account, add timestamp * swaping the git-source for vsphere-automation-sdk-python * Remove destroy, handled in context manager Co-authored-by: Daniel Wozniak <dwozniak@saltstack.com> Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@wiked.org> Co-authored-by: Hoa-Long Tam <hoalong@apple.com> Co-authored-by: krionbsd <krion@freebsd.org> Co-authored-by: Elias Probst <e.probst@ssc-services.de> Co-authored-by: Daniel A. Wozniak <dwozniak@vmware.com> Co-authored-by: Frode Gundersen <frogunder@gmail.com> Co-authored-by: twangboy <slee@saltstack.com> Co-authored-by: twangboy <leesh@vmware.com> Co-authored-by: ScriptAutomate <derek@icanteven.io> Co-authored-by: Wayne Werner <waynejwerner@gmail.com> Co-authored-by: David Murphy < dmurphy@saltstack.com> Co-authored-by: Joe Eacott <jeacott@vmware.com> Co-authored-by: cmcmarrow <charles.mcmarrow.4@gmail.com> Co-authored-by: Twangboy <shane.d.lee@gmail.com>
2021-09-22 20:42:38 -04:00
if crypto:
session_run_always(
session,
Merge 3003.3 into master (#60924) * Merge 3002.6 bugfix changes (#59822) * Pass `CI_RUN` as an environment variable to the test run. This allows us to know if we're running the test suite under a CI environment or not and adapt/adjust if needed * Migrate `unit.setup` to PyTest * Backport ae36b15 just for test_install.py * Only skip tests on CI runs * Always store git sha in _version.py during installation * Fix PEP440 compliance. The wheel metadata version 1.2 states that the package version MUST be PEP440 compliant. This means that instead of `3002.2-511-g033c53eccb`, the salt version string should look like `3002.2+511.g033c53eccb`, a post release of `3002.2` ahead by 511 commits with the git sha `033c53eccb` * Fix and migrate `tests/unit/test_version.py` to PyTest * Skip test if `easy_install` is not available * We also need to be PEP440 compliant when there's no git history * Allow extra_filerefs as sanitized kwargs for SSH client * Fix regression on cmd.run when passing tuples as cmd Co-authored-by: Alexander Graul <agraul@suse.com> * Add unit tests to ensure cmd.run accepts tuples * Add unit test to check for extra_filerefs on SSH opts * Add changelog file * Fix comment for test case * Fix unit test to avoid failing on Windows * Skip failing test on windows * Fix test to work on Windows * Add all ssh kwargs to sanitize_kwargs method * Run pre-commit * Fix pylint * Fix cmdmod loglevel and module_names tests * Fix pre-commit * Skip ssh tests if binary does not exist * Use setup_loader for cmdmod test * Prevent argument injection in restartcheck * Add changelog for restartcheck fix * docs_3002.6 * Add back tests removed in merge Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> * Remove glance state module in favor of glance_image * update wording in changelog * bump deprecation warning to Silicon. * Updating warnutil version to Phosphorous. * Update salt/modules/keystone.py Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Check $HOMEBREW_PREFIX when linking against libcrypto When loading `libcrypto`, Salt checks for a Homebrew installation of `openssl` at Homebrew's default prefix of `/usr/local`. However, on Apple Silicon Macs, Homebrew's default installation prefix is `/opt/homebrew`. On all platforms, the prefix is configurable. If Salt doesn't find one of those `libcrypto`s, it will fall back on the un-versioned `/usr/lib/libcrypto.dylib`, which will cause the following crash: Application Specific Information: /usr/lib/libcrypto.dylib abort() called Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI. This commit checks $HOMEBREW_PREFIX instead of hard-coding `/usr/local`. * Add test case * Add changelog for 59808 * Add changelog entry * Make _find_libcrypto fail on Big Sur if it can't find a library Right now, if `_find_libcrypto` can't find any externally-managed versions of libcrypto, it will fall back on the pre-Catalina un-versioned system libcrypto. This does not exist on Big Sur and it would be better to raise an exception here rather than crashing later when trying to open it. * Update _find_libcrypto tests This commit simplifies the unit tests for _find_libcrypto by mocking out the host's filesystem and testing the common libcrypto installations (brew, ports, etc.) on Big Sur. It simplifies the tests for falling back on system versions of libcrypto on previous versions of macOS. * Fix description of test_find_libcrypto_with_system_before_catalina * Patch sys.platform for test_rsax931 tests * modules/match: add missing "minion_id" in Pillar example The documented Pillar example for `match.filter_by` lacks the `minion_id` parameter. Without it, the assignment won't work as expected. - fix documentation - add tests: - to prove the misbehavior of the documented example - to prove the proper behaviour when supplying `minion_id` - to ensure some misbehaviour observed with compound matchers doesn't occur * Fix for issue #59773 - When instantiating the loader grab values of grains and pillars if they are NamedLoaderContext instances. - The loader uses a copy of opts. - Impliment deepcopy on NamedLoaderContext instances. * Add changelog for #59773 * _get_initial_pillar function returns pillar * Fix linter issues * Clean up test * Bump deprecation release for neutron * Uncomment Sulfur release name * Removing the _ext_nodes deprecation warning and alias. * Adding changelog. * Renaming changelog file. * Update 59804.removed * Initial pass at fips_mode config option * Fix pre-commit * Fix tests and add changelog * update docs 3003 * update docs 3003 - newline * Fix warts in changelog * update releasenotes 3003 * add ubuntu-2004-amd64 m2crypto pycryptodome and tcp tests * add distro_arch * changing the cloud platforms file missed in 1a9b7be0e2f300d87924731dc5816fd1000cd22b * Update __utils__ calls to import utils in azure * Add changelog for 59744 * Fix azure unit tests and move to pytest * Use contextvars from site-packages for thin If a contextvars package exists one of the site-packages locations use it for the generated thin tarball. This overrides python's builtin contextvars and allows salt-ssh to work with python <=3.6 even when the master's python is >3.6 (Fixes #59942) * Add regression test for #59942 * Add changelog for #59942 * Update filemap to include test_py_versions * Fix broken thin tests * Always install the `contextvars` backport, even on Py3.7+ Without this change, salt-ssh cannot target systems with Python <= 3.6 * Use salt-factories to handle the container. Don't override default roster * Fix thin tests on windows * No need to use warn log level here * Fix getsitepackages for old virtualenv versions * Add explicit pyobjc reqs * Add back the passthrough stuff * Remove a line so pre-commit will run * Bugfix release docs * Bugfix release docs * Removing pip-compile log files * Bump requirements to address a few security issues * Address traceback on macOS ``` Traceback (most recent call last): File "setup.py", line 1448, in <module> setup(distclass=SaltDistribution) File "/Users/jenkins/setup-tests/.venv/lib/python3.7/site-packages/setuptools/__init__.py", line 153, in setup return distutils.core.setup(**attrs) File "/opt/salt/lib/python3.7/distutils/core.py", line 108, in setup _setup_distribution = dist = klass(attrs) File "setup.py", line 1068, in __init__ self.update_metadata() File "setup.py", line 1074, in update_metadata attrvalue = getattr(self, attrname, None) File "setup.py", line 1182, in _property_install_requires install_requires += _parse_requirements_file(reqfile) File "setup.py", line 270, in _parse_requirements_file platform.python_version(), _parse_op(op), _parse_ver(ver) File "setup.py", line 247, in _check_ver return getattr(operator, "__{}__".format(op))(pyver, wanted) File "/opt/salt/lib/python3.7/distutils/version.py", line 46, in __eq__ c = self._cmp(other) File "/opt/salt/lib/python3.7/distutils/version.py", line 337, in _cmp if self.version < other.version: TypeError: '<' not supported between instances of 'str' and 'int' ``` * Replace `saltstack.com` with `saltproject.io` on URLs being tested * Add back support to load old entrypoints by iterating instead of type checking Fixes #59961 * Fix issue #59975 * Fix pillar serialization for jinja #60083 * Fix test * Add changelog for #60083 * Update changelog and release for 3003.1 * Remove the changelog source refs * Add connect to IPCMessageSubscriber's async_methods Fixes #60049 by making sure an IPCMessageSubscriber that is wrapped by SyncWrapper has a connect method that runs the coroutine rather than returns a fugure. * Add changelog for #60049 * Update 60049.fixed * Fix coroutine spelling error Co-authored-by: Wayne Werner <waynejwerner@gmail.com> * IPC on windows cannot use socket paths Fixes #60298 * Update Jinja2 and lxml due to security related bugfix releases Jinja2 ------ CVE-2020-28493 moderate severity Vulnerable versions: < 2.11.3 Patched version: 2.11.3 This affects the package jinja2 from 0.0.0 and before 2.11.3. The ReDOS vulnerability of the regex is mainly due to the sub-pattern [a-zA-Z0-9.-]+.[a-zA-Z0-9.-]+ This issue can be mitigated by Markdown to format user content instead of the urlize filter, or by implementing request timeouts and limiting process memory. lxml ---- CVE-2021-28957 moderate severity Vulnerable versions: < 4.6.3 Patched version: 4.6.3 An XSS vulnerability was discovered in the python lxml clean module versions before 4.6.3. When disabling the safe_attrs_only and forms arguments, the Cleaner class does not remove the formaction attribute allowing for JS to bypass the sanitizer. A remote attacker could exploit this flaw to run arbitrary JS code on users who interact with incorrectly sanitized HTML. This issue is patched in lxml 4.6.3. * fix github actions jobs on branch until bullseye comes out * Upgrade to `six==1.16.0` to avoid problems on CI runs ``` 13:59:02 nox > Session invoke-pre-commit was successful. 13:59:02 nox > Running session invoke-pre-commit 13:59:02 nox > pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt 13:59:02 Collecting blessings==1.7 13:59:02 Using cached blessings-1.7-py3-none-any.whl (18 kB) 13:59:02 Collecting invoke==1.4.1 13:59:02 Using cached invoke-1.4.1-py3-none-any.whl (210 kB) 13:59:02 Collecting pyyaml==5.3.1 13:59:02 Using cached PyYAML-5.3.1.tar.gz (269 kB) 13:59:02 Collecting six==1.15.0 13:59:02 Using cached six-1.15.0-py2.py3-none-any.whl (10 kB) 13:59:02 Building wheels for collected packages: pyyaml 13:59:02 Building wheel for pyyaml (setup.py) ... - \ | / - \ | done 13:59:02 Created wheel for pyyaml: filename=PyYAML-5.3.1-cp37-cp37m-linux_x86_64.whl size=546391 sha256=e42e1d66cc32087f4d33ceb81268c86b59f1a97029b19459f91b8d6ad1430167 13:59:02 Stored in directory: /var/jenkins/.cache/pip/wheels/5e/03/1e/e1e954795d6f35dfc7b637fe2277bff021303bd9570ecea653 13:59:02 Successfully built pyyaml 13:59:02 Installing collected packages: six, pyyaml, invoke, blessings 13:59:02 Attempting uninstall: six 13:59:02 Found existing installation: six 1.16.0 13:59:02 Uninstalling six-1.16.0: 13:59:02 ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/var/jenkins/.cache/pre-commit/repomw8oee1s/py_env-python3/lib/python3.7/site-packages/__pycache__/six.cpython-37.pyc' 13:59:02 13:59:02 nox > Command pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt failed with exit code 1 13:59:02 nox > Session invoke-pre-commit failed. ``` * add changelog for https://github.com/saltstack/salt/issues/59982 * Regression test for #56273 * Fix race condition in batch. #56273 * Add changelog for #56273 * Update salt/client/__init__.py Co-authored-by: Pedro Algarvio <pedro@algarvio.me> * Update doc for salt/client * Update changelog/56273.fixed Thoreau said, "Simplify, Simplify" * Update docs * Update docs * Update CHANGELOG.md * Update 3003.1.rst * Ignore configuration for 'enable_fqdns_grains' for AIX, Solaris and Juniper * Added changelog * Let Mac OS Mojave run for 8 hours to avoid timeout * Remove FreeBSD-12.2 * Use Popen for VT * Still allow shell True * Drop shlex split * Add crypto re-init * Fix pre-commit * Do not call close in isalive * Skip tests not valid on windows * Cleanup things that are not really needed * We do not support irix * Fix pre-commit * Remove commented out lines * Add changelog for #60504 * Fix pre-commit issues * pyupgrade does not remove six imports * Fix OSErrors in some test cases * Remove un-needed args processing * Make state_running test more reliable * Removing tmpfs from Fedora 33. * Address leaks in fileserver caused by git backends At this time we do not have the ability to fix the upstream memory leaks in the gitfs backend providers. Work around their limitations by periodically restarting the file server update proccess. This will at least partially address #50313 * Remove un-used import * Fix warts caused by black version * Add changelog * We don't need two changelogs * Also pin the ``pip`` upgrade to be ``<21.2`` * Update the external ipaddress to the latest 3.9.5 version which has some security fixes. Updating the compat.p to use the vendored version if the python version is below 3.9.5 and only run the test_ipaddress.py tests if below 3.9.5. * Adding changelog * Requested changes. * Add shh_timeout to ssh_kwargs * move to with blocks * one with block * reight crypto * add back test file * add changelog * change log file number * add m2crypt support * only check m2crpto * Delete 60571.fixed * add back log * add newline * add newline for log file * Work around https://github.com/pypa/pip/pull/9450 See https://github.com/pypa/pip/issues/10212 * Drop six and Py2 * [3003.2] Add server alive (#60573) * add server alive * rename log * change default alive time * add requested changes * format string * reformat string again * run pre * customize * space * remove EOF dead space * fix pre-commit * run pre Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Changelog for 3003.2 * Man pages update for 3003.2 * Allow CVE entries in `changelog/` * Add security type for towncrier changelog * Add security type for changelog entries pre-commit check * Pin to ``pip>=20.2.4,<21.2`` Refs https://github.com/pypa/pip/pull/9450 * Drop six and Py2 * Fix bug introduced in https://github.com/saltstack/salt/pull/59648 Fixes #60046 * Add changelog * Fix doc builds * fix release notes about dropping ubuntu 16.04 * update file client * add changelog file * update changelog * Check permissions of minion config directory * Fix some wording in the messagebox and in comments * Add changelog * Fix extension for changelog * Add missing commas. It also worked, but now is better * docs_3003.3 * fixing version numbers in man pages. * removing newlines. * removing newlines. * Fixing release notes. * Fix changelog file for 3003.2 release * Fix test_state test using loader.context * Re-add test_context test * Allow Local System account, add timestamp * swaping the git-source for vsphere-automation-sdk-python * Remove destroy, handled in context manager Co-authored-by: Daniel Wozniak <dwozniak@saltstack.com> Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@wiked.org> Co-authored-by: Hoa-Long Tam <hoalong@apple.com> Co-authored-by: krionbsd <krion@freebsd.org> Co-authored-by: Elias Probst <e.probst@ssc-services.de> Co-authored-by: Daniel A. Wozniak <dwozniak@vmware.com> Co-authored-by: Frode Gundersen <frogunder@gmail.com> Co-authored-by: twangboy <slee@saltstack.com> Co-authored-by: twangboy <leesh@vmware.com> Co-authored-by: ScriptAutomate <derek@icanteven.io> Co-authored-by: Wayne Werner <waynejwerner@gmail.com> Co-authored-by: David Murphy < dmurphy@saltstack.com> Co-authored-by: Joe Eacott <jeacott@vmware.com> Co-authored-by: cmcmarrow <charles.mcmarrow.4@gmail.com> Co-authored-by: Twangboy <shane.d.lee@gmail.com>
2021-09-22 20:42:38 -04:00
"pip",
"uninstall",
"-y",
"m2crypto",
"pycrypto",
"pycryptodome",
"pycryptodomex",
silent=True,
)
install_command = [
"--progress-bar=off",
"--constraint",
_get_pip_requirements_file(session, crypto=True),
Merge 3003.3 into master (#60924) * Merge 3002.6 bugfix changes (#59822) * Pass `CI_RUN` as an environment variable to the test run. This allows us to know if we're running the test suite under a CI environment or not and adapt/adjust if needed * Migrate `unit.setup` to PyTest * Backport ae36b15 just for test_install.py * Only skip tests on CI runs * Always store git sha in _version.py during installation * Fix PEP440 compliance. The wheel metadata version 1.2 states that the package version MUST be PEP440 compliant. This means that instead of `3002.2-511-g033c53eccb`, the salt version string should look like `3002.2+511.g033c53eccb`, a post release of `3002.2` ahead by 511 commits with the git sha `033c53eccb` * Fix and migrate `tests/unit/test_version.py` to PyTest * Skip test if `easy_install` is not available * We also need to be PEP440 compliant when there's no git history * Allow extra_filerefs as sanitized kwargs for SSH client * Fix regression on cmd.run when passing tuples as cmd Co-authored-by: Alexander Graul <agraul@suse.com> * Add unit tests to ensure cmd.run accepts tuples * Add unit test to check for extra_filerefs on SSH opts * Add changelog file * Fix comment for test case * Fix unit test to avoid failing on Windows * Skip failing test on windows * Fix test to work on Windows * Add all ssh kwargs to sanitize_kwargs method * Run pre-commit * Fix pylint * Fix cmdmod loglevel and module_names tests * Fix pre-commit * Skip ssh tests if binary does not exist * Use setup_loader for cmdmod test * Prevent argument injection in restartcheck * Add changelog for restartcheck fix * docs_3002.6 * Add back tests removed in merge Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> * Remove glance state module in favor of glance_image * update wording in changelog * bump deprecation warning to Silicon. * Updating warnutil version to Phosphorous. * Update salt/modules/keystone.py Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Check $HOMEBREW_PREFIX when linking against libcrypto When loading `libcrypto`, Salt checks for a Homebrew installation of `openssl` at Homebrew's default prefix of `/usr/local`. However, on Apple Silicon Macs, Homebrew's default installation prefix is `/opt/homebrew`. On all platforms, the prefix is configurable. If Salt doesn't find one of those `libcrypto`s, it will fall back on the un-versioned `/usr/lib/libcrypto.dylib`, which will cause the following crash: Application Specific Information: /usr/lib/libcrypto.dylib abort() called Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI. This commit checks $HOMEBREW_PREFIX instead of hard-coding `/usr/local`. * Add test case * Add changelog for 59808 * Add changelog entry * Make _find_libcrypto fail on Big Sur if it can't find a library Right now, if `_find_libcrypto` can't find any externally-managed versions of libcrypto, it will fall back on the pre-Catalina un-versioned system libcrypto. This does not exist on Big Sur and it would be better to raise an exception here rather than crashing later when trying to open it. * Update _find_libcrypto tests This commit simplifies the unit tests for _find_libcrypto by mocking out the host's filesystem and testing the common libcrypto installations (brew, ports, etc.) on Big Sur. It simplifies the tests for falling back on system versions of libcrypto on previous versions of macOS. * Fix description of test_find_libcrypto_with_system_before_catalina * Patch sys.platform for test_rsax931 tests * modules/match: add missing "minion_id" in Pillar example The documented Pillar example for `match.filter_by` lacks the `minion_id` parameter. Without it, the assignment won't work as expected. - fix documentation - add tests: - to prove the misbehavior of the documented example - to prove the proper behaviour when supplying `minion_id` - to ensure some misbehaviour observed with compound matchers doesn't occur * Fix for issue #59773 - When instantiating the loader grab values of grains and pillars if they are NamedLoaderContext instances. - The loader uses a copy of opts. - Impliment deepcopy on NamedLoaderContext instances. * Add changelog for #59773 * _get_initial_pillar function returns pillar * Fix linter issues * Clean up test * Bump deprecation release for neutron * Uncomment Sulfur release name * Removing the _ext_nodes deprecation warning and alias. * Adding changelog. * Renaming changelog file. * Update 59804.removed * Initial pass at fips_mode config option * Fix pre-commit * Fix tests and add changelog * update docs 3003 * update docs 3003 - newline * Fix warts in changelog * update releasenotes 3003 * add ubuntu-2004-amd64 m2crypto pycryptodome and tcp tests * add distro_arch * changing the cloud platforms file missed in 1a9b7be0e2f300d87924731dc5816fd1000cd22b * Update __utils__ calls to import utils in azure * Add changelog for 59744 * Fix azure unit tests and move to pytest * Use contextvars from site-packages for thin If a contextvars package exists one of the site-packages locations use it for the generated thin tarball. This overrides python's builtin contextvars and allows salt-ssh to work with python <=3.6 even when the master's python is >3.6 (Fixes #59942) * Add regression test for #59942 * Add changelog for #59942 * Update filemap to include test_py_versions * Fix broken thin tests * Always install the `contextvars` backport, even on Py3.7+ Without this change, salt-ssh cannot target systems with Python <= 3.6 * Use salt-factories to handle the container. Don't override default roster * Fix thin tests on windows * No need to use warn log level here * Fix getsitepackages for old virtualenv versions * Add explicit pyobjc reqs * Add back the passthrough stuff * Remove a line so pre-commit will run * Bugfix release docs * Bugfix release docs * Removing pip-compile log files * Bump requirements to address a few security issues * Address traceback on macOS ``` Traceback (most recent call last): File "setup.py", line 1448, in <module> setup(distclass=SaltDistribution) File "/Users/jenkins/setup-tests/.venv/lib/python3.7/site-packages/setuptools/__init__.py", line 153, in setup return distutils.core.setup(**attrs) File "/opt/salt/lib/python3.7/distutils/core.py", line 108, in setup _setup_distribution = dist = klass(attrs) File "setup.py", line 1068, in __init__ self.update_metadata() File "setup.py", line 1074, in update_metadata attrvalue = getattr(self, attrname, None) File "setup.py", line 1182, in _property_install_requires install_requires += _parse_requirements_file(reqfile) File "setup.py", line 270, in _parse_requirements_file platform.python_version(), _parse_op(op), _parse_ver(ver) File "setup.py", line 247, in _check_ver return getattr(operator, "__{}__".format(op))(pyver, wanted) File "/opt/salt/lib/python3.7/distutils/version.py", line 46, in __eq__ c = self._cmp(other) File "/opt/salt/lib/python3.7/distutils/version.py", line 337, in _cmp if self.version < other.version: TypeError: '<' not supported between instances of 'str' and 'int' ``` * Replace `saltstack.com` with `saltproject.io` on URLs being tested * Add back support to load old entrypoints by iterating instead of type checking Fixes #59961 * Fix issue #59975 * Fix pillar serialization for jinja #60083 * Fix test * Add changelog for #60083 * Update changelog and release for 3003.1 * Remove the changelog source refs * Add connect to IPCMessageSubscriber's async_methods Fixes #60049 by making sure an IPCMessageSubscriber that is wrapped by SyncWrapper has a connect method that runs the coroutine rather than returns a fugure. * Add changelog for #60049 * Update 60049.fixed * Fix coroutine spelling error Co-authored-by: Wayne Werner <waynejwerner@gmail.com> * IPC on windows cannot use socket paths Fixes #60298 * Update Jinja2 and lxml due to security related bugfix releases Jinja2 ------ CVE-2020-28493 moderate severity Vulnerable versions: < 2.11.3 Patched version: 2.11.3 This affects the package jinja2 from 0.0.0 and before 2.11.3. The ReDOS vulnerability of the regex is mainly due to the sub-pattern [a-zA-Z0-9.-]+.[a-zA-Z0-9.-]+ This issue can be mitigated by Markdown to format user content instead of the urlize filter, or by implementing request timeouts and limiting process memory. lxml ---- CVE-2021-28957 moderate severity Vulnerable versions: < 4.6.3 Patched version: 4.6.3 An XSS vulnerability was discovered in the python lxml clean module versions before 4.6.3. When disabling the safe_attrs_only and forms arguments, the Cleaner class does not remove the formaction attribute allowing for JS to bypass the sanitizer. A remote attacker could exploit this flaw to run arbitrary JS code on users who interact with incorrectly sanitized HTML. This issue is patched in lxml 4.6.3. * fix github actions jobs on branch until bullseye comes out * Upgrade to `six==1.16.0` to avoid problems on CI runs ``` 13:59:02 nox > Session invoke-pre-commit was successful. 13:59:02 nox > Running session invoke-pre-commit 13:59:02 nox > pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt 13:59:02 Collecting blessings==1.7 13:59:02 Using cached blessings-1.7-py3-none-any.whl (18 kB) 13:59:02 Collecting invoke==1.4.1 13:59:02 Using cached invoke-1.4.1-py3-none-any.whl (210 kB) 13:59:02 Collecting pyyaml==5.3.1 13:59:02 Using cached PyYAML-5.3.1.tar.gz (269 kB) 13:59:02 Collecting six==1.15.0 13:59:02 Using cached six-1.15.0-py2.py3-none-any.whl (10 kB) 13:59:02 Building wheels for collected packages: pyyaml 13:59:02 Building wheel for pyyaml (setup.py) ... - \ | / - \ | done 13:59:02 Created wheel for pyyaml: filename=PyYAML-5.3.1-cp37-cp37m-linux_x86_64.whl size=546391 sha256=e42e1d66cc32087f4d33ceb81268c86b59f1a97029b19459f91b8d6ad1430167 13:59:02 Stored in directory: /var/jenkins/.cache/pip/wheels/5e/03/1e/e1e954795d6f35dfc7b637fe2277bff021303bd9570ecea653 13:59:02 Successfully built pyyaml 13:59:02 Installing collected packages: six, pyyaml, invoke, blessings 13:59:02 Attempting uninstall: six 13:59:02 Found existing installation: six 1.16.0 13:59:02 Uninstalling six-1.16.0: 13:59:02 ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/var/jenkins/.cache/pre-commit/repomw8oee1s/py_env-python3/lib/python3.7/site-packages/__pycache__/six.cpython-37.pyc' 13:59:02 13:59:02 nox > Command pip install --progress-bar=off -r requirements/static/ci/py3.7/invoke.txt failed with exit code 1 13:59:02 nox > Session invoke-pre-commit failed. ``` * add changelog for https://github.com/saltstack/salt/issues/59982 * Regression test for #56273 * Fix race condition in batch. #56273 * Add changelog for #56273 * Update salt/client/__init__.py Co-authored-by: Pedro Algarvio <pedro@algarvio.me> * Update doc for salt/client * Update changelog/56273.fixed Thoreau said, "Simplify, Simplify" * Update docs * Update docs * Update CHANGELOG.md * Update 3003.1.rst * Ignore configuration for 'enable_fqdns_grains' for AIX, Solaris and Juniper * Added changelog * Let Mac OS Mojave run for 8 hours to avoid timeout * Remove FreeBSD-12.2 * Use Popen for VT * Still allow shell True * Drop shlex split * Add crypto re-init * Fix pre-commit * Do not call close in isalive * Skip tests not valid on windows * Cleanup things that are not really needed * We do not support irix * Fix pre-commit * Remove commented out lines * Add changelog for #60504 * Fix pre-commit issues * pyupgrade does not remove six imports * Fix OSErrors in some test cases * Remove un-needed args processing * Make state_running test more reliable * Removing tmpfs from Fedora 33. * Address leaks in fileserver caused by git backends At this time we do not have the ability to fix the upstream memory leaks in the gitfs backend providers. Work around their limitations by periodically restarting the file server update proccess. This will at least partially address #50313 * Remove un-used import * Fix warts caused by black version * Add changelog * We don't need two changelogs * Also pin the ``pip`` upgrade to be ``<21.2`` * Update the external ipaddress to the latest 3.9.5 version which has some security fixes. Updating the compat.p to use the vendored version if the python version is below 3.9.5 and only run the test_ipaddress.py tests if below 3.9.5. * Adding changelog * Requested changes. * Add shh_timeout to ssh_kwargs * move to with blocks * one with block * reight crypto * add back test file * add changelog * change log file number * add m2crypt support * only check m2crpto * Delete 60571.fixed * add back log * add newline * add newline for log file * Work around https://github.com/pypa/pip/pull/9450 See https://github.com/pypa/pip/issues/10212 * Drop six and Py2 * [3003.2] Add server alive (#60573) * add server alive * rename log * change default alive time * add requested changes * format string * reformat string again * run pre * customize * space * remove EOF dead space * fix pre-commit * run pre Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com> * Changelog for 3003.2 * Man pages update for 3003.2 * Allow CVE entries in `changelog/` * Add security type for towncrier changelog * Add security type for changelog entries pre-commit check * Pin to ``pip>=20.2.4,<21.2`` Refs https://github.com/pypa/pip/pull/9450 * Drop six and Py2 * Fix bug introduced in https://github.com/saltstack/salt/pull/59648 Fixes #60046 * Add changelog * Fix doc builds * fix release notes about dropping ubuntu 16.04 * update file client * add changelog file * update changelog * Check permissions of minion config directory * Fix some wording in the messagebox and in comments * Add changelog * Fix extension for changelog * Add missing commas. It also worked, but now is better * docs_3003.3 * fixing version numbers in man pages. * removing newlines. * removing newlines. * Fixing release notes. * Fix changelog file for 3003.2 release * Fix test_state test using loader.context * Re-add test_context test * Allow Local System account, add timestamp * swaping the git-source for vsphere-automation-sdk-python * Remove destroy, handled in context manager Co-authored-by: Daniel Wozniak <dwozniak@saltstack.com> Co-authored-by: Pedro Algarvio <pedro@algarvio.me> Co-authored-by: Bryce Larson <brycel@vmware.com> Co-authored-by: Pablo Suárez Hernández <psuarezhernandez@suse.com> Co-authored-by: Alexander Graul <agraul@suse.com> Co-authored-by: Frode Gundersen <fgundersen@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@saltstack.com> Co-authored-by: Gareth J. Greenaway <gareth@wiked.org> Co-authored-by: Hoa-Long Tam <hoalong@apple.com> Co-authored-by: krionbsd <krion@freebsd.org> Co-authored-by: Elias Probst <e.probst@ssc-services.de> Co-authored-by: Daniel A. Wozniak <dwozniak@vmware.com> Co-authored-by: Frode Gundersen <frogunder@gmail.com> Co-authored-by: twangboy <slee@saltstack.com> Co-authored-by: twangboy <leesh@vmware.com> Co-authored-by: ScriptAutomate <derek@icanteven.io> Co-authored-by: Wayne Werner <waynejwerner@gmail.com> Co-authored-by: David Murphy < dmurphy@saltstack.com> Co-authored-by: Joe Eacott <jeacott@vmware.com> Co-authored-by: cmcmarrow <charles.mcmarrow.4@gmail.com> Co-authored-by: Twangboy <shane.d.lee@gmail.com>
2021-09-22 20:42:38 -04:00
]
install_command.append(crypto)
session.install(*install_command, silent=PIP_INSTALL_SILENT)
cmd_args = [
f"--transport={transport}",
] + session.posargs
_pytest(session, coverage=coverage, cmd_args=cmd_args)
2019-03-25 15:07:39 +00:00
@nox.session(python=_PYTHON_VERSIONS)
@nox.parametrize("coverage", [False, True])
def test(session, coverage):
2020-04-02 20:10:20 -05:00
"""
pytest session with zeromq transport and default crypto
2020-04-02 20:10:20 -05:00
"""
session.notify(
find_session_runner(
session,
"test-parametrized",
session.python,
coverage=coverage,
crypto=None,
transport="zeromq",
)
)
2019-03-25 15:07:39 +00:00
@nox.session(python=_PYTHON_VERSIONS)
@nox.parametrize("coverage", [False, True])
def pytest(session, coverage):
"""
pytest session with zeromq transport and default crypto
"""
try:
session_name = session.name
except AttributeError:
session_name = session._runner.friendly_name
session_warn(
session,
"This nox session is deprecated, please call {!r} instead".format(
session_name.replace("pytest-", "test-")
),
)
session.notify(session_name.replace("pytest-", "test-"))
@nox.session(python=_PYTHON_VERSIONS, name="test-tcp")
@nox.parametrize("coverage", [False, True])
def test_tcp(session, coverage):
"""
pytest session with TCP transport and default crypto
"""
session.notify(
find_session_runner(
session,
"test-parametrized",
session.python,
coverage=coverage,
crypto=None,
transport="tcp",
)
)
2019-04-05 15:57:30 +01:00
@nox.session(python=_PYTHON_VERSIONS, name="pytest-tcp")
@nox.parametrize("coverage", [False, True])
def pytest_tcp(session, coverage):
2020-04-02 20:10:20 -05:00
"""
2019-04-05 15:57:30 +01:00
pytest session with TCP transport and default crypto
2020-04-02 20:10:20 -05:00
"""
try:
session_name = session.name
except AttributeError:
session_name = session._runner.friendly_name
session_warn(
session,
"This nox session is deprecated, please call {!r} instead".format(
session_name.replace("pytest-", "test-")
),
)
session.notify(session_name.replace("pytest-", "test-"))
@nox.session(python=_PYTHON_VERSIONS, name="test-zeromq")
@nox.parametrize("coverage", [False, True])
def test_zeromq(session, coverage):
"""
pytest session with zeromq transport and default crypto
"""
2019-04-05 15:57:30 +01:00
session.notify(
find_session_runner(
session,
"test-parametrized",
session.python,
coverage=coverage,
crypto=None,
transport="zeromq",
2019-04-05 15:57:30 +01:00
)
)
@nox.session(python=_PYTHON_VERSIONS, name="pytest-zeromq")
@nox.parametrize("coverage", [False, True])
def pytest_zeromq(session, coverage):
2020-04-02 20:10:20 -05:00
"""
pytest session with zeromq transport and default crypto
2020-04-02 20:10:20 -05:00
"""
try:
session_name = session.name
except AttributeError:
session_name = session._runner.friendly_name
session_warn(
session,
"This nox session is deprecated, please call {!r} instead".format(
session_name.replace("pytest-", "test-")
),
)
session.notify(session_name.replace("pytest-", "test-"))
@nox.session(python=_PYTHON_VERSIONS, name="test-m2crypto")
@nox.parametrize("coverage", [False, True])
def test_m2crypto(session, coverage):
"""
pytest session with zeromq transport and m2crypto
"""
session.notify(
find_session_runner(
session,
"test-parametrized",
session.python,
coverage=coverage,
crypto="m2crypto",
transport="zeromq",
)
)
2019-03-25 15:07:39 +00:00
@nox.session(python=_PYTHON_VERSIONS, name="pytest-m2crypto")
@nox.parametrize("coverage", [False, True])
def pytest_m2crypto(session, coverage):
2020-04-02 20:10:20 -05:00
"""
pytest session with zeromq transport and m2crypto
2020-04-02 20:10:20 -05:00
"""
try:
session_name = session.name
except AttributeError:
session_name = session._runner.friendly_name
session_warn(
session,
"This nox session is deprecated, please call {!r} instead".format(
session_name.replace("pytest-", "test-")
),
)
session.notify(session_name.replace("pytest-", "test-"))
@nox.session(python=_PYTHON_VERSIONS, name="test-tcp-m2crypto")
@nox.parametrize("coverage", [False, True])
def test_tcp_m2crypto(session, coverage):
"""
pytest session with TCP transport and m2crypto
"""
session.notify(
find_session_runner(
session,
"test-parametrized",
session.python,
coverage=coverage,
crypto="m2crypto",
transport="tcp",
)
)
2019-04-05 15:57:30 +01:00
@nox.session(python=_PYTHON_VERSIONS, name="pytest-tcp-m2crypto")
@nox.parametrize("coverage", [False, True])
def pytest_tcp_m2crypto(session, coverage):
2020-04-02 20:10:20 -05:00
"""
2019-04-05 15:57:30 +01:00
pytest session with TCP transport and m2crypto
2020-04-02 20:10:20 -05:00
"""
try:
session_name = session.name
except AttributeError:
session_name = session._runner.friendly_name
session_warn(
session,
"This nox session is deprecated, please call {!r} instead".format(
session_name.replace("pytest-", "test-")
),
)
session.notify(session_name.replace("pytest-", "test-"))
@nox.session(python=_PYTHON_VERSIONS, name="test-zeromq-m2crypto")
@nox.parametrize("coverage", [False, True])
def test_zeromq_m2crypto(session, coverage):
"""
pytest session with zeromq transport and m2crypto
"""
2019-04-05 15:57:30 +01:00
session.notify(
find_session_runner(
session,
"test-parametrized",
session.python,
coverage=coverage,
crypto="m2crypto",
transport="zeromq",
2019-04-05 15:57:30 +01:00
)
)
@nox.session(python=_PYTHON_VERSIONS, name="pytest-zeromq-m2crypto")
@nox.parametrize("coverage", [False, True])
def pytest_zeromq_m2crypto(session, coverage):
2020-04-02 20:10:20 -05:00
"""
pytest session with zeromq transport and m2crypto
2020-04-02 20:10:20 -05:00
"""
try:
session_name = session.name
except AttributeError:
session_name = session._runner.friendly_name
session_warn(
session,
"This nox session is deprecated, please call {!r} instead".format(
session_name.replace("pytest-", "test-")
),
)
session.notify(session_name.replace("pytest-", "test-"))
@nox.session(python=_PYTHON_VERSIONS, name="test-pycryptodome")
@nox.parametrize("coverage", [False, True])
def test_pycryptodome(session, coverage):
"""
pytest session with zeromq transport and pycryptodome
"""
session.notify(
find_session_runner(
session,
"test-parametrized",
session.python,
coverage=coverage,
crypto="pycryptodome",
transport="zeromq",
)
)
@nox.session(python=_PYTHON_VERSIONS, name="pytest-pycryptodome")
2019-03-25 15:07:39 +00:00
@nox.parametrize("coverage", [False, True])
def pytest_pycryptodome(session, coverage):
2020-04-02 20:10:20 -05:00
"""
pytest session with zeromq transport and pycryptodome
2020-04-02 20:10:20 -05:00
"""
try:
session_name = session.name
except AttributeError:
session_name = session._runner.friendly_name
session_warn(
session,
"This nox session is deprecated, please call {!r} instead".format(
session_name.replace("pytest-", "test-")
),
)
session.notify(session_name.replace("pytest-", "test-"))
@nox.session(python=_PYTHON_VERSIONS, name="test-tcp-pycryptodome")
@nox.parametrize("coverage", [False, True])
def test_tcp_pycryptodome(session, coverage):
"""
pytest session with TCP transport and pycryptodome
"""
session.notify(
find_session_runner(
session,
"test-parametrized",
session.python,
coverage=coverage,
crypto="pycryptodome",
transport="tcp",
)
)
@nox.session(python=_PYTHON_VERSIONS, name="pytest-tcp-pycryptodome")
2019-04-05 15:57:30 +01:00
@nox.parametrize("coverage", [False, True])
def pytest_tcp_pycryptodome(session, coverage):
2020-04-02 20:10:20 -05:00
"""
pytest session with TCP transport and pycryptodome
2020-04-02 20:10:20 -05:00
"""
try:
session_name = session.name
except AttributeError:
session_name = session._runner.friendly_name
session_warn(
session,
"This nox session is deprecated, please call {!r} instead".format(
session_name.replace("pytest-", "test-")
),
)
session.notify(session_name.replace("pytest-", "test-"))
@nox.session(python=_PYTHON_VERSIONS, name="test-zeromq-pycryptodome")
@nox.parametrize("coverage", [False, True])
def test_zeromq_pycryptodome(session, coverage):
"""
pytest session with zeromq transport and pycryptodome
"""
2019-04-05 15:57:30 +01:00
session.notify(
find_session_runner(
session,
"test-parametrized",
session.python,
coverage=coverage,
crypto="pycryptodome",
transport="zeromq",
2019-04-05 15:57:30 +01:00
)
)
@nox.session(python=_PYTHON_VERSIONS, name="pytest-zeromq-pycryptodome")
@nox.parametrize("coverage", [False, True])
def pytest_zeromq_pycryptodome(session, coverage):
2020-04-02 20:10:20 -05:00
"""
pytest session with zeromq transport and pycryptodome
2020-04-02 20:10:20 -05:00
"""
try:
session_name = session.name
except AttributeError:
session_name = session._runner.friendly_name
session_warn(
session,
"This nox session is deprecated, please call {!r} instead".format(
session_name.replace("pytest-", "test-")
),
)
session.notify(session_name.replace("pytest-", "test-"))
@nox.session(python=_PYTHON_VERSIONS, name="test-cloud")
@nox.parametrize("coverage", [False, True])
def test_cloud(session, coverage):
"""
pytest cloud tests session
"""
2021-09-23 14:42:44 +01:00
pydir = _get_pydir(session)
if pydir == "py3.5":
session.error(
"Due to conflicting and unsupported requirements the cloud tests only run on Py3.6+"
)
# Install requirements
if _upgrade_pip_setuptools_and_wheel(session):
linux_requirements_file = os.path.join(
"requirements", "static", "ci", pydir, "linux.txt"
)
cloud_requirements_file = os.path.join(
2021-09-23 14:42:44 +01:00
"requirements", "static", "ci", pydir, "cloud.txt"
)
install_command = [
"--progress-bar=off",
"-r",
linux_requirements_file,
"-r",
cloud_requirements_file,
]
session.install(*install_command, silent=PIP_INSTALL_SILENT)
cmd_args = [
2020-04-09 11:32:38 +01:00
"--run-expensive",
"-k",
"cloud",
] + session.posargs
_pytest(session, coverage=coverage, cmd_args=cmd_args)
@nox.session(python=_PYTHON_VERSIONS, name="pytest-cloud")
@nox.parametrize("coverage", [False, True])
def pytest_cloud(session, coverage):
"""
pytest cloud tests session
"""
try:
session_name = session.name
except AttributeError:
session_name = session._runner.friendly_name
session_warn(
session,
"This nox session is deprecated, please call {!r} instead".format(
session_name.replace("pytest-", "test-")
),
)
session.notify(session_name.replace("pytest-", "test-"))
@nox.session(python=_PYTHON_VERSIONS, name="test-tornado")
@nox.parametrize("coverage", [False, True])
def test_tornado(session, coverage):
"""
pytest tornado tests session
"""
# Install requirements
if _upgrade_pip_setuptools_and_wheel(session):
_install_requirements(session)
session.install(
"--progress-bar=off", "tornado==5.0.2", silent=PIP_INSTALL_SILENT
)
session.install(
"--progress-bar=off", "pyzmq==17.0.0", silent=PIP_INSTALL_SILENT
)
_pytest(session, coverage=coverage, cmd_args=session.posargs)
@nox.session(python=_PYTHON_VERSIONS, name="pytest-tornado")
@nox.parametrize("coverage", [False, True])
def pytest_tornado(session, coverage):
"""
pytest tornado tests session
"""
try:
session_name = session.name
except AttributeError:
session_name = session._runner.friendly_name
session_warn(
session,
"This nox session is deprecated, please call {!r} instead".format(
session_name.replace("pytest-", "test-")
),
)
session.notify(session_name.replace("pytest-", "test-"))
def _pytest(session, coverage, cmd_args, env=None, on_rerun=False):
# Create required artifacts directories
_create_ci_directories()
if env is None:
env = {}
env["CI_RUN"] = "1" if CI_RUN else "0"
args = [
"--rootdir",
str(REPO_ROOT),
2019-06-08 18:19:01 +01:00
"--log-file-level=debug",
2020-05-22 16:18:55 +01:00
"--show-capture=no",
"-ra",
"-s",
"-vv",
"--showlocals",
]
for arg in cmd_args:
if arg == "--log-file" or arg.startswith("--log-file="):
break
else:
args.append(f"--log-file={RUNTESTS_LOGFILE}")
args.extend(cmd_args)
if PRINT_SYSTEM_INFO_ONLY and "--sys-info-and-exit" not in args:
args.append("--sys-info-and-exit")
session.run("python", "-m", "pytest", *args, env=env)
return
if PRINT_SYSTEM_INFO and "--sysinfo" not in args:
args.append("--sysinfo")
if PRINT_TEST_SELECTION:
# We'll print out the collected tests on CI runs.
# This will show a full list of what tests are going to run, in the right order, which, in case
# of a test suite hang, helps us pinpoint which test is hanging
session.run(
"python", "-m", "pytest", *(args + ["--collect-only", "-qqq"]), env=env
)
if PRINT_TEST_PLAN_ONLY:
return
if coverage is True:
_coverage_cmd_args = []
if "COVERAGE_CONTEXT" in os.environ:
_coverage_cmd_args.append(f"--context={os.environ['COVERAGE_CONTEXT']}")
_run_with_coverage(
session,
"python",
"-m",
"coverage",
"run",
*_coverage_cmd_args,
"-m",
"pytest",
*args,
env=env,
on_rerun=on_rerun,
)
else:
session.run("python", "-m", "pytest", *args, env=env)
def _ci_test(session, transport, onedir=False):
# Install requirements
_install_requirements(session, onedir=onedir)
env = {}
if onedir:
env["ONEDIR_TESTRUN"] = "1"
chunks = {
"pkg": [
"tests/pytests/pkg",
],
"unit": [
"tests/unit",
"tests/pytests/unit",
],
"functional": [
"tests/pytests/functional",
],
"scenarios": [
"tests/pytests/scenarios",
],
}
test_group_number = os.environ.get("TEST_GROUP") or "1"
if not session.posargs:
chunk_cmd = []
junit_report_filename = "test-results"
runtests_log_filename = "runtests"
else:
chunk = session.posargs.pop(0)
if chunk in ["unit", "functional", "integration", "scenarios", "all"]:
if chunk == "all":
chunk_cmd = []
junit_report_filename = "test-results"
runtests_log_filename = "runtests"
elif chunk == "integration":
chunk_cmd = []
for values in chunks.values():
for value in values:
chunk_cmd.append(f"--ignore={value}")
junit_report_filename = f"test-results-{chunk}-grp{test_group_number}"
runtests_log_filename = f"runtests-{chunk}-grp{test_group_number}"
else:
chunk_cmd = chunks[chunk]
junit_report_filename = f"test-results-{chunk}-grp{test_group_number}"
runtests_log_filename = f"runtests-{chunk}-grp{test_group_number}"
if session.posargs:
if session.posargs[0] == "--":
session.posargs.pop(0)
chunk_cmd.extend(session.posargs)
else:
chunk_cmd = [chunk] + session.posargs
junit_report_filename = f"test-results-grp{test_group_number}"
runtests_log_filename = f"runtests-grp{test_group_number}"
rerun_failures = os.environ.get("RERUN_FAILURES", "0") == "1"
track_code_coverage = os.environ.get("SKIP_CODE_COVERAGE", "0") == "0"
common_pytest_args = [
"--color=yes",
"--ssh-tests",
"--sys-stats",
"--run-destructive",
f"--output-columns={os.environ.get('OUTPUT_COLUMNS') or 120}",
]
try:
pytest_args = (
common_pytest_args[:]
+ [
f"--junitxml=artifacts/xml-unittests-output/{junit_report_filename}.xml",
f"--log-file=artifacts/logs/{runtests_log_filename}.log",
]
+ chunk_cmd
)
_pytest(session, coverage=track_code_coverage, cmd_args=pytest_args, env=env)
except CommandFailed:
if rerun_failures is False:
raise
# Don't print the system information, not the test selection on reruns
global PRINT_TEST_SELECTION
global PRINT_SYSTEM_INFO
PRINT_TEST_SELECTION = False
PRINT_SYSTEM_INFO = False
pytest_args = (
common_pytest_args[:]
+ [
"--lf",
f"--junitxml=artifacts/xml-unittests-output/{junit_report_filename}-rerun.xml",
f"--log-file=artifacts/logs/{runtests_log_filename}-rerun.log",
]
+ chunk_cmd
)
_pytest(
session,
coverage=track_code_coverage,
cmd_args=pytest_args,
env=env,
on_rerun=True,
)
@nox.session(python=_PYTHON_VERSIONS, name="ci-test")
def ci_test(session):
transport = os.environ.get("SALT_TRANSPORT") or "zeromq"
valid_transports = ("zeromq", "tcp")
if transport not in valid_transports:
session.error(
"The value for the SALT_TRANSPORT environment variable can only be "
f"one of: {', '.join(valid_transports)}"
)
_ci_test(session, transport)
@nox.session(python=_PYTHON_VERSIONS, name="ci-test-tcp")
def ci_test_tcp(session):
_ci_test(session, "tcp")
@nox.session(
python=str(ONEDIR_PYTHON_PATH),
name="ci-test-onedir",
venv_params=["--system-site-packages"],
)
def ci_test_onedir(session):
if not ONEDIR_ARTIFACT_PATH.exists():
session.error(
"The salt onedir artifact, expected to be in '{}', was not found".format(
ONEDIR_ARTIFACT_PATH.relative_to(REPO_ROOT)
)
)
transport = os.environ.get("SALT_TRANSPORT") or "zeromq"
valid_transports = ("zeromq", "tcp")
if transport not in valid_transports:
session.error(
"The value for the SALT_TRANSPORT environment variable can only be "
f"one of: {', '.join(valid_transports)}"
)
_ci_test(session, "zeromq", onedir=True)
@nox.session(
python=str(ONEDIR_PYTHON_PATH),
name="ci-test-onedir-tcp",
venv_params=["--system-site-packages"],
)
def ci_test_onedir_tcp(session):
if not ONEDIR_ARTIFACT_PATH.exists():
session.error(
"The salt onedir artifact, expected to be in '{}', was not found".format(
ONEDIR_ARTIFACT_PATH.relative_to(REPO_ROOT)
)
)
_ci_test(session, "tcp", onedir=True)
@nox.session(python="3", name="report-coverage")
def report_coverage(session):
_report_coverage(session, combine=True, cli_report=True)
@nox.session(python="3", name="coverage-report")
def coverage_report(session):
_report_coverage(session, combine=True, cli_report=True)
@nox.session(python=False, name="decompress-dependencies")
def decompress_dependencies(session):
if not session.posargs:
session.error(
"The 'decompress-dependencies' session target needs "
"two arguments, '<platform> <arch>'."
)
try:
platform = session.posargs.pop(0)
arch = session.posargs.pop(0)
if session.posargs:
session.error(
"The 'decompress-dependencies' session target only accepts "
"two arguments, '<platform> <arch>'."
)
except IndexError:
session.error(
"The 'decompress-dependencies' session target needs "
"two arguments, '<platform> <arch>'."
)
if platform == "windows":
extension = "tar.gz"
scripts_dir_name = "Scripts"
else:
extension = "tar.xz"
scripts_dir_name = "bin"
nox_dependencies_tarball = f"nox.{platform}.{arch}.{extension}"
nox_dependencies_tarball_path = REPO_ROOT / nox_dependencies_tarball
if not nox_dependencies_tarball_path.exists():
session.error(
f"The {nox_dependencies_tarball} file "
"does not exist. Not decompressing anything."
)
session_run_always(session, "tar", "xpf", nox_dependencies_tarball)
if os.environ.get("DELETE_NOX_ARCHIVE", "0") == "1":
nox_dependencies_tarball_path.unlink()
session.log("Finding broken 'python' symlinks under '.nox/' ...")
for dirname in os.scandir(REPO_ROOT / ".nox"):
scan_path = REPO_ROOT.joinpath(".nox", dirname, scripts_dir_name)
script_paths = {str(p): p for p in os.scandir(scan_path)}
fixed_shebang = f"#!{scan_path / 'python'}"
for key in sorted(script_paths):
path = script_paths[key]
if path.is_symlink():
broken_link = pathlib.Path(path)
resolved_link = os.readlink(path)
if not os.path.isabs(resolved_link):
# Relative symlinks, resolve them
resolved_link = os.path.join(scan_path, resolved_link)
2024-11-04 13:09:17 -07:00
prefix_check = False
if platform == "windows":
prefix_check = resolved_link.startswith("\\\\?")
if not os.path.exists(resolved_link) or prefix_check:
session.log("The symlink %r looks to be broken", resolved_link)
# This is a broken link, fix it
resolved_link_suffix = resolved_link.split(
f"artifacts{os.sep}salt{os.sep}"
)[-1]
fixed_link = REPO_ROOT.joinpath(
"artifacts", "salt", resolved_link_suffix
)
session.log(
"Fixing broken symlink in nox virtualenv %r, from %r to %r",
dirname.name,
resolved_link,
str(fixed_link.relative_to(REPO_ROOT)),
)
broken_link.unlink()
broken_link.symlink_to(fixed_link)
continue
if not path.is_file():
continue
if platform != "windows":
# Let's try to fix shebang's
try:
fpath = pathlib.Path(path)
contents = fpath.read_text(encoding="utf-8").splitlines()
if (
contents[0].startswith("#!")
and contents[0].endswith("python")
and contents[0] != fixed_shebang
):
session.log(
"Fixing broken shebang in %r",
str(fpath.relative_to(REPO_ROOT)),
)
fpath.write_text(
"\n".join([fixed_shebang] + contents[1:]), encoding="utf-8"
)
except UnicodeDecodeError:
pass
@nox.session(python=False, name="compress-dependencies")
def compress_dependencies(session):
if not session.posargs:
session.error(
"The 'compress-dependencies' session target needs "
"two arguments, '<platform> <arch>'."
)
try:
platform = session.posargs.pop(0)
arch = session.posargs.pop(0)
if session.posargs:
session.error(
"The 'compress-dependencies' session target only accepts "
"two arguments, '<platform> <arch>'."
)
except IndexError:
session.error(
"The 'compress-dependencies' session target needs "
"two arguments, '<platform> <arch>'."
)
if platform == "windows":
extension = "tar.gz"
else:
extension = "tar.xz"
nox_dependencies_tarball = f"nox.{platform}.{arch}.{extension}"
nox_dependencies_tarball_path = REPO_ROOT / nox_dependencies_tarball
if nox_dependencies_tarball_path.exists():
session_warn(
session, f"Found existing {nox_dependencies_tarball}. Deleting it."
)
nox_dependencies_tarball_path.unlink()
session_run_always(
session,
"tar",
"-caf",
nox_dependencies_tarball,
"--exclude=.nox/pre-archive-cleanup",
".nox",
)
@nox.session(
python=str(ONEDIR_PYTHON_PATH),
name="pre-archive-cleanup",
)
@nox.parametrize("pkg", [False, True])
def pre_archive_cleanup(session, pkg):
"""
Call `tools pkg pre-archive-cleanup <path>`
"""
if session.posargs:
session.error("No additional arguments can be passed to 'pre-archive-cleanup'")
version_info = _get_session_python_version_info(session)
if version_info < (3, 10):
session.error(
"The nox session 'pre-archive-cleanup' needs Python 3.10+ to run."
)
if _upgrade_pip_setuptools_and_wheel(session):
requirements_file = os.path.join(
"requirements", "static", "ci", _get_pydir(session), "tools.txt"
)
install_command = ["--progress-bar=off", "-r", requirements_file]
session.install(*install_command, silent=PIP_INSTALL_SILENT)
cmdline = [
"tools",
"pkg",
"pre-archive-cleanup",
]
if pkg:
cmdline.append("--pkg")
cmdline.append(".nox")
session_run_always(session, *cmdline)
@nox.session(python="3", name="combine-coverage")
def combine_coverage(session):
_report_coverage(session, combine=True, cli_report=False)
@nox.session(
python=str(ONEDIR_PYTHON_PATH),
name="combine-coverage-onedir",
venv_params=["--system-site-packages"],
)
def combine_coverage_onedir(session):
_report_coverage(session, combine=True, cli_report=False)
@nox.session(python="3", name="create-html-coverage-report")
def create_html_coverage_report(session):
_report_coverage(session, combine=True, cli_report=False, html_report=True)
def _create_xml_coverage_reports(session):
if session.posargs:
session.error("No arguments are acceptable to this nox session.")
session.posargs.append("salt")
_report_coverage(session, combine=True, cli_report=False, xml_report=True)
session.posargs.append("tests")
_report_coverage(session, combine=True, cli_report=False, xml_report=True)
@nox.session(python="3", name="create-xml-coverage-reports")
def create_xml_coverage_reports(session):
_create_xml_coverage_reports(session)
@nox.session(
python=str(ONEDIR_PYTHON_PATH),
name="create-xml-coverage-reports-onedir",
venv_params=["--system-site-packages"],
)
def create_xml_coverage_reports_onedir(session):
_create_xml_coverage_reports(session)
@nox.session(python="3", name="create-json-coverage-reports")
def create_json_coverage_reports(session):
_report_coverage(session, combine=True, cli_report=False, json_report=True)
@nox.session(
python=str(ONEDIR_PYTHON_PATH),
name="create-json-coverage-reports-onedir",
venv_params=["--system-site-packages"],
)
def create_json_coverage_reports_onedir(session):
_report_coverage(session, combine=True, cli_report=False, json_report=True)
class Tee:
2020-04-02 20:10:20 -05:00
"""
Python class to mimic linux tee behaviour
2020-04-02 20:10:20 -05:00
"""
def __init__(self, first, second):
self._first = first
self._second = second
def write(self, b):
wrote = self._first.write(b)
self._first.flush()
self._second.write(b)
self._second.flush()
def fileno(self):
return self._first.fileno()
def _lint(session, rcfile, flags, paths, upgrade_setuptools_and_pip=True):
if _upgrade_pip_setuptools_and_wheel(session, upgrade=upgrade_setuptools_and_pip):
linux_requirements_file = os.path.join(
"requirements", "static", "ci", _get_pydir(session), "linux.txt"
)
lint_requirements_file = os.path.join(
"requirements", "static", "ci", _get_pydir(session), "lint.txt"
)
install_command = [
"--progress-bar=off",
"-r",
linux_requirements_file,
"-r",
lint_requirements_file,
]
session.install(*install_command, silent=PIP_INSTALL_SILENT)
2020-01-03 13:30:03 +00:00
cmd_args = ["pylint", f"--rcfile={rcfile}"] + list(flags) + list(paths)
2020-01-03 13:30:03 +00:00
cmd_kwargs = {"env": {"PYTHONUNBUFFERED": "1"}}
session.run(*cmd_args, **cmd_kwargs)
2020-01-03 13:30:03 +00:00
def _lint_pre_commit(session, rcfile, flags, paths):
if "VIRTUAL_ENV" not in os.environ:
session.error(
"This should be running from within a virtualenv and "
"'VIRTUAL_ENV' was not found as an environment variable."
)
if "pre-commit" not in os.environ["VIRTUAL_ENV"]:
session.error(
"This should be running from within a pre-commit virtualenv and "
"'VIRTUAL_ENV'({}) does not appear to be a pre-commit virtualenv.".format(
os.environ["VIRTUAL_ENV"]
)
)
from nox.virtualenv import VirtualEnv
2020-04-02 20:10:20 -05:00
2020-01-03 13:30:03 +00:00
# Let's patch nox to make it run inside the pre-commit virtualenv
session._runner.venv = VirtualEnv(
os.environ["VIRTUAL_ENV"],
interpreter=session._runner.func.python,
reuse_existing=True,
venv=True,
)
_lint(
session,
rcfile,
flags,
paths,
upgrade_setuptools_and_pip=False,
)
2019-12-03 10:57:49 +00:00
@nox.session(python="3")
def lint(session):
2020-04-02 20:10:20 -05:00
"""
Run PyLint against Salt and it's test suite.
2020-04-02 20:10:20 -05:00
"""
session.notify(f"lint-salt-{session.python}")
session.notify(f"lint-tests-{session.python}")
2019-12-03 10:57:49 +00:00
@nox.session(python="3", name="lint-salt")
def lint_salt(session):
2020-04-02 20:10:20 -05:00
"""
Run PyLint against Salt.
2020-04-02 20:10:20 -05:00
"""
flags = ["--disable=I"]
if session.posargs:
paths = session.posargs
else:
# TBD replace paths entries when implement pyproject.toml
paths = ["setup.py", "noxfile.py", "salt/", "tools/"]
2019-12-03 10:57:49 +00:00
_lint(session, ".pylintrc", flags, paths)
2019-12-03 10:57:49 +00:00
@nox.session(python="3", name="lint-tests")
def lint_tests(session):
2020-04-02 20:10:20 -05:00
"""
Run PyLint against Salt and it's test suite.
2020-04-02 20:10:20 -05:00
"""
flags = ["--disable=I"]
if session.posargs:
paths = session.posargs
else:
paths = ["tests/"]
2019-12-03 10:57:49 +00:00
_lint(session, ".pylintrc", flags, paths)
2019-04-02 17:16:49 +01:00
2020-01-03 13:30:03 +00:00
@nox.session(python=False, name="lint-salt-pre-commit")
def lint_salt_pre_commit(session):
2020-04-02 20:10:20 -05:00
"""
Run PyLint against Salt.
2020-04-02 20:10:20 -05:00
"""
2020-01-03 13:30:03 +00:00
flags = ["--disable=I"]
if session.posargs:
paths = session.posargs
else:
paths = ["setup.py", "noxfile.py", "salt/", "tools/"]
2020-01-03 13:30:03 +00:00
_lint_pre_commit(session, ".pylintrc", flags, paths)
@nox.session(python=False, name="lint-tests-pre-commit")
def lint_tests_pre_commit(session):
2020-04-02 20:10:20 -05:00
"""
Run PyLint against Salt and it's test suite.
2020-04-02 20:10:20 -05:00
"""
2020-01-03 13:30:03 +00:00
flags = ["--disable=I"]
if session.posargs:
paths = session.posargs
else:
paths = ["tests/"]
_lint_pre_commit(session, ".pylintrc", flags, paths)
@nox.session(python="3")
2020-08-07 16:16:08 -04:00
@nox.parametrize("clean", [False, True])
@nox.parametrize("update", [False, True])
@nox.parametrize("compress", [False, True])
2020-08-07 16:16:08 -04:00
def docs(session, compress, update, clean):
2020-04-02 20:10:20 -05:00
"""
2019-04-02 17:16:49 +01:00
Build Salt's Documentation
2020-04-02 20:10:20 -05:00
"""
session.notify(f"docs-html-{session.python}(compress={compress})")
session.notify(
find_session_runner(
session,
"docs-man",
session.python,
compress=compress,
update=update,
2020-08-07 16:16:08 -04:00
clean=clean,
)
)
@nox.session(name="docs-html", python="3")
2020-08-07 16:16:08 -04:00
@nox.parametrize("clean", [False, True])
@nox.parametrize("compress", [False, True])
2020-08-07 16:16:08 -04:00
def docs_html(session, compress, clean):
2020-04-02 20:10:20 -05:00
"""
Build Salt's HTML Documentation
2020-04-02 20:10:20 -05:00
"""
if _upgrade_pip_setuptools_and_wheel(session):
linux_requirements_file = os.path.join(
"requirements", "static", "ci", _get_pydir(session), "linux.txt"
)
base_requirements_file = os.path.join("requirements", "base.txt")
zeromq_requirements_file = os.path.join("requirements", "zeromq.txt")
docs_requirements_file = os.path.join(
"requirements", "static", "ci", _get_pydir(session), "docs.txt"
)
install_command = [
"--progress-bar=off",
"--constraint",
linux_requirements_file,
"-r",
base_requirements_file,
"-r",
zeromq_requirements_file,
"-r",
docs_requirements_file,
]
session.install(*install_command, silent=PIP_INSTALL_SILENT)
2019-04-02 17:16:49 +01:00
os.chdir("doc/")
2020-08-07 16:16:08 -04:00
if clean:
session.run("make", "clean", external=True)
2019-05-29 11:28:55 +01:00
session.run("make", "html", "SPHINXOPTS=-W", external=True)
if compress:
session.run("tar", "-cJvf", "html-archive.tar.xz", "_build/html", external=True)
os.chdir("..")
@nox.session(name="docs-man", python="3")
2020-08-07 16:16:08 -04:00
@nox.parametrize("clean", [False, True])
@nox.parametrize("update", [False, True])
@nox.parametrize("compress", [False, True])
2020-08-07 16:16:08 -04:00
def docs_man(session, compress, update, clean):
2020-04-02 20:10:20 -05:00
"""
Build Salt's Manpages Documentation
2020-04-02 20:10:20 -05:00
"""
if _upgrade_pip_setuptools_and_wheel(session):
linux_requirements_file = os.path.join(
"requirements", "static", "ci", _get_pydir(session), "linux.txt"
)
base_requirements_file = os.path.join("requirements", "base.txt")
zeromq_requirements_file = os.path.join("requirements", "zeromq.txt")
docs_requirements_file = os.path.join(
"requirements", "static", "ci", _get_pydir(session), "docs.txt"
)
install_command = [
"--progress-bar=off",
"--constraint",
linux_requirements_file,
"-r",
base_requirements_file,
"-r",
zeromq_requirements_file,
"-r",
docs_requirements_file,
]
session.install(*install_command, silent=PIP_INSTALL_SILENT)
os.chdir("doc/")
2020-08-07 16:16:08 -04:00
if clean:
session.run("make", "clean", external=True)
session.run("make", "man", "SPHINXOPTS=-W", external=True)
if update:
session.run("rm", "-rf", "man/", external=True)
session.run("cp", "-Rp", "_build/man", "man/", external=True)
if compress:
session.run("tar", "-cJvf", "man-archive.tar.xz", "_build/man", external=True)
2019-04-02 17:16:49 +01:00
os.chdir("..")
2020-04-23 11:48:17 +01:00
2020-04-14 18:37:33 -04:00
@nox.session(name="changelog", python="3")
@nox.parametrize("draft", [False, True])
@nox.parametrize("force", [False, True])
def changelog(session, draft, force):
2020-04-14 18:37:33 -04:00
"""
Generate salt's changelog
"""
session_warn(
session,
"Please stop using this nox session and start using the 'tools' command shown below.",
)
if _upgrade_pip_setuptools_and_wheel(session):
requirements_file = os.path.join(
"requirements", "static", "ci", _get_pydir(session), "tools.txt"
)
install_command = ["--progress-bar=off", "-r", requirements_file]
session.install(*install_command, silent=PIP_INSTALL_SILENT)
2020-04-14 18:37:33 -04:00
cmd = ["tools", "changelog", "update-changelog-md"]
2020-04-14 18:37:33 -04:00
if draft:
cmd.append("--draft")
cmd.append(session.posargs[0])
session.run(*cmd)
class Recompress:
"""
Helper class to re-compress a ``.tag.gz`` file to make it reproducible.
"""
def __init__(self, mtime):
self.mtime = int(mtime)
def tar_reset(self, tarinfo):
"""
Reset user, group, mtime, and mode to create reproducible tar.
"""
tarinfo.uid = tarinfo.gid = 0
tarinfo.uname = tarinfo.gname = "root"
tarinfo.mtime = self.mtime
if tarinfo.type == tarfile.DIRTYPE:
tarinfo.mode = 0o755
else:
tarinfo.mode = 0o644
if tarinfo.pax_headers:
raise ValueError(tarinfo.name, tarinfo.pax_headers)
return tarinfo
def recompress(self, targz):
"""
Re-compress the passed path.
"""
tempd = pathlib.Path(tempfile.mkdtemp()).resolve()
d_src = tempd.joinpath("src")
d_src.mkdir()
d_tar = tempd.joinpath(targz.stem)
d_targz = tempd.joinpath(targz.name)
with tarfile.open(d_tar, "w|") as wfile:
with tarfile.open(targz, "r:gz") as rfile:
2024-02-27 10:24:22 +00:00
rfile.extractall(d_src) # nosec
extracted_dir = next(pathlib.Path(d_src).iterdir())
for name in sorted(extracted_dir.rglob("*")):
wfile.add(
str(name),
filter=self.tar_reset,
recursive=False,
arcname=str(name.relative_to(d_src)),
)
with open(d_tar, "rb") as rfh:
with gzip.GzipFile(
fileobj=open(d_targz, "wb"), mode="wb", filename="", mtime=self.mtime
) as gz: # pylint: disable=invalid-name
while True:
chunk = rfh.read(1024)
if not chunk:
break
gz.write(chunk)
targz.unlink()
shutil.move(str(d_targz), str(targz))
@nox.session(python="3")
def build(session):
"""
Build source and binary distributions based off the current commit author date UNIX timestamp.
The reason being, reproducible packages.
.. code-block: shell
git show -s --format=%at HEAD
"""
shutil.rmtree("dist/", ignore_errors=True)
if SKIP_REQUIREMENTS_INSTALL is False:
session.install(
"--progress-bar=off",
"-r",
"requirements/build.txt",
silent=PIP_INSTALL_SILENT,
)
timestamp = session.run(
"git",
"show",
"-s",
"--format=%at",
"HEAD",
silent=True,
log=False,
stderr=None,
).strip()
env = {"SOURCE_DATE_EPOCH": str(timestamp)}
session.run(
"python",
"-m",
"build",
"--sdist",
str(REPO_ROOT),
env=env,
)
# Recreate sdist to be reproducible
recompress = Recompress(timestamp)
for targz in REPO_ROOT.joinpath("dist").glob("*.tar.gz"):
session.log("Re-compressing %s...", targz.relative_to(REPO_ROOT))
recompress.recompress(targz)
sha256sum = shutil.which("sha256sum")
if sha256sum:
packages = [
str(pkg.relative_to(REPO_ROOT))
for pkg in REPO_ROOT.joinpath("dist").iterdir()
]
session.run("sha256sum", *packages, external=True)
session.run("python", "-m", "twine", "check", "dist/*")
@nox.session(
python=str(ONEDIR_PYTHON_PATH),
name="ci-test-onedir-pkgs",
venv_params=["--system-site-packages"],
)
def ci_test_onedir_pkgs(session):
from nox.virtualenv import VirtualEnv
session_warn(session, "Replacing VirtualEnv instance...")
ci_test_onedir_path = REPO_ROOT / ".nox" / "ci-test-onedir"
2024-12-07 01:52:45 -07:00
if hasattr(session._runner.venv, "venv_or_virtualenv"):
venv = session._runner.venv.venv_or_virtualenv == "venv"
session._runner.venv = VirtualEnv(
str(ci_test_onedir_path.relative_to(REPO_ROOT)),
interpreter=session._runner.func.python,
reuse_existing=True,
venv=venv,
venv_params=session._runner.venv.venv_params,
)
else:
venv = session._runner.venv.venv_backend in ("venv", "virtualenv")
session._runner.venv = VirtualEnv( # pylint: disable=unexpected-keyword-arg
str(ci_test_onedir_path.relative_to(REPO_ROOT)),
interpreter=session._runner.func.python,
reuse_existing=True,
venv_backend=session._runner.venv.venv_backend,
venv_params=session._runner.venv.venv_params,
)
os.environ["VIRTUAL_ENV"] = session._runner.venv.location
session._runner.venv.create()
if not ONEDIR_ARTIFACT_PATH.exists():
session.error(
"The salt onedir artifact, expected to be in '{}', was not found".format(
ONEDIR_ARTIFACT_PATH.relative_to(REPO_ROOT)
)
)
common_pytest_args = [
"--color=yes",
"--sys-stats",
"--run-destructive",
f"--output-columns={os.environ.get('OUTPUT_COLUMNS') or 120}",
"--pkg-system-service",
]
chunks = {
"install": [],
"upgrade": [
"--upgrade",
"--no-uninstall",
],
2023-07-31 18:08:38 -04:00
"downgrade": [
"--downgrade",
"--no-uninstall",
],
"download-pkgs": [
"--download-pkgs",
],
}
if not session.posargs or session.posargs[0] not in chunks:
chunk = "install"
session.log("Choosing default 'install' test type")
else:
chunk = session.posargs.pop(0)
cmd_args = chunks[chunk]
for arg in session.posargs:
if arg.startswith("tests/pytests/pkg/"):
# The user is passing test paths
cmd_args.pop()
break
if IS_LINUX:
# Fetch the toolchain
session_run_always(session, "python3", "-m", "relenv", "toolchain", "fetch")
# Install requirements
if _upgrade_pip_setuptools_and_wheel(session):
_install_requirements(session, "pyzmq")
env = {
"ONEDIR_TESTRUN": "1",
"PKG_TEST_TYPE": chunk,
}
pytest_args = (
common_pytest_args[:]
+ cmd_args[:]
+ [
f"--junitxml=artifacts/xml-unittests-output/test-results-{chunk}.xml",
f"--log-file=artifacts/logs/runtests-{chunk}.log",
]
+ session.posargs
)
append_tests_path = True
test_paths = (
"tests/pytests/pkg/",
str(REPO_ROOT / "tests" / "pytests" / "pkg"),
)
for arg in session.posargs:
if arg.startswith(test_paths):
append_tests_path = False
break
if append_tests_path:
pytest_args.append("tests/pytests/pkg/")
try:
_pytest(session, coverage=False, cmd_args=pytest_args, env=env)
except CommandFailed:
if os.environ.get("RERUN_FAILURES", "0") == "0":
# Don't rerun on failures
return
# Don't print the system information, not the test selection on reruns
global PRINT_TEST_SELECTION
global PRINT_SYSTEM_INFO
PRINT_TEST_SELECTION = False
PRINT_SYSTEM_INFO = False
pytest_args = (
common_pytest_args[:]
+ cmd_args[:]
+ [
f"--junitxml=artifacts/xml-unittests-output/test-results-{chunk}-rerun.xml",
f"--log-file=artifacts/logs/runtests-{chunk}-rerun.log",
"--lf",
]
+ session.posargs
)
if append_tests_path:
pytest_args.append("tests/pytests/pkg/")
_pytest(
session,
coverage=False,
cmd_args=pytest_args,
env=env,
on_rerun=True,
)
if chunk not in ("install", "download-pkgs"):
cmd_args = chunks[chunk]
pytest_args = (
common_pytest_args[:]
+ cmd_args[:]
+ [
"--junitxml=artifacts/xml-unittests-output/test-results-install.xml",
"--log-file=artifacts/logs/runtests-install.log",
]
+ session.posargs
)
if "downgrade" in chunk:
pytest_args.append("--use-prev-version")
if append_tests_path:
pytest_args.append("tests/pytests/pkg/")
try:
_pytest(session, coverage=False, cmd_args=pytest_args, env=env)
except CommandFailed:
if os.environ.get("RERUN_FAILURES", "0") == "0":
# Don't rerun on failures
return
cmd_args = chunks[chunk]
pytest_args = (
common_pytest_args[:]
+ cmd_args[:]
+ [
"--junitxml=artifacts/xml-unittests-output/test-results-install-rerun.xml",
"--log-file=artifacts/logs/runtests-install-rerun.log",
"--lf",
]
+ session.posargs
)
if "downgrade" in chunk:
pytest_args.append("--use-prev-version")
if append_tests_path:
pytest_args.append("tests/pytests/pkg/")
_pytest(
session,
coverage=False,
cmd_args=pytest_args,
env=env,
on_rerun=True,
)
sys.exit(0)