Skip to content

Instantly share code, notes, and snippets.

View abadger's full-sized avatar

Toshio Kuratomi abadger

View GitHub Profile
diff --git a/tests/integration/tier0/check-cve-2022-1662/main.fmf b/tests/integration/tier0/check-cve-2022-1662/main.fmf
index 7da180d..bf7c36b 100644
--- a/tests/integration/tier0/check-cve-2022-1662/main.fmf
+++ b/tests/integration/tier0/check-cve-2022-1662/main.fmf
@@ -3,4 +3,6 @@ summary: check cve-2022-1662 is fixed
tier: 0
test: |
+ yum install -y python3-devel
+ pip install psutil
+-------------------------------+------------+
|message id |occurrences |
+===============================+============+
|consider-using-f-string |182 | Disable until we can require python-3.6+
+-------------------------------+------------+
|logging-not-lazy |123 | `log.warn("Message %s" % var)` => `log.warn("Message %s", var)`
+-------------------------------+------------+
|useless-object-inheritance |17 | Add `__metaclass__ = type` to the top of all files and remove `object` from class
+-------------------------------+------------+
|logging-format-interpolation |13 |
# Bad code:
class Foo:
def one(self, normalize):
self.normalize = normalize
self.username = os.geteuid()
self.token = os.environ['TOKEN']
data = self.do_a_thing()
if some_check():
data2 = self.do_a_thing()
# Three ways to do for loops:
## The common way
Most of the time, you have an iterable (a list, dictionary, string, etc) and want to loop over it.
Python makes this the easiest way to use a for loop:
``` python
contestants = ["First place finisher", "Second is still good", "the first civilized age"]
for contestant in contestants:
@abadger
abadger / .vimrc.py
Created December 10, 2021 18:46
My .vimrc.py Requires amoffat/snake
import snake
@snake.key_map("<leader>R")
def reverse():
"""Test mapping. Reverse a word"""
snake.replace_word(snake.get_word()[::-1])
@snake.key_map("<c-p>")
@abadger
abadger / gist:615c9d85a201c3f61c6673172e3a7b46
Created December 2, 2021 16:47
Example of easy porting of run_suprocess to use a list
diff --git a/convert2rhel/checks.py b/convert2rhel/checks.py
index 1bb5dff..ebe481f 100644
--- a/convert2rhel/checks.py
+++ b/convert2rhel/checks.py
@@ -105,7 +105,7 @@ def check_tainted_kmods():
system76_io 16384 0 - Live 0x0000000000000000 (OE) <<<<<< Tainted
system76_acpi 16384 0 - Live 0x0000000000000000 (OE) <<<<< Tainted
"""
- unsigned_modules, _ = run_subprocess("grep '(' /proc/modules")
+ unsigned_modules, _ = run_subprocess(["grep", "('", "/proc/modules"])
@abadger
abadger / gist:ea234ee7a7238b343bcfd6537d6e92e7
Last active November 30, 2021 20:34
Calling subprocess.Popen with strings.

Background of security problem

When you call suprocess.Popen, you can pass the command to execute in two ways:

  1. A string that corresponds to the commandline that you would run at the shell prompt command = "yum whatprovides 'java = 1.8.0'"
  2. A list where each argument to the command is a separate entry: command = ["yum", "whatprovides", "java = 1.8.0"]

When you pass a string to subprocess.Popen, the command has to either have no arguments or be passed through the shell

@abadger
abadger / gist:2e9bdb59ee7d42dfc0d612dcef07d67d
Created November 10, 2021 18:10
Convert2rhel unit testing discussion 11-10-2021
* Integration tests
* DevDocTest
* Hackathon that made the new CI framework work with testing_farm (and
Artemis) and pakit. These are used in Fedora and RHEL
* https://packit.dev/docs/testing-farm/
* Developers should be able to write these but now that we have a QE team then
they can write them
* We might re-evaluate having the developers write these in the future.
* Runs the whole conversion:
* Set up the system
diff --git a/convert2rhel/unit_tests/logger_test.py b/convert2rhel/unit_tests/logger_test.py
index 1679f66..78477cc 100644
--- a/convert2rhel/unit_tests/logger_test.py
+++ b/convert2rhel/unit_tests/logger_test.py
@@ -119,20 +119,29 @@ def test_logger_custom_logger(tmpdir, caplog):
("convert2rhel.log", True, False, True),
),
)
-@mock.patch("os.stat")
-def test_archive_old_logger_files(os_stat, log_name, path_exists, is_dir, exception, monkeypatch, caplog):
@abadger
abadger / latest.log
Created July 26, 2021 01:14
minecolonies builder won't build asian plantation 2
[25Jul2021 16:59:20.114] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, AnonymousBadger, --version, MultiMC5, --gameDir, /home/badger/bin/MultiMC/instances/FTB Presents Direwolf20 1.16/minecraft, --assetsDir, /home/badger/bin/MultiMC/assets, --assetIndex, 1.16, --uuid, ec7bc4c4c50a4cf3b1beeb9e6302df9a, --accessToken, ❄❄❄❄❄❄❄❄, --userType, mojang, --versionType, release, --launchTarget, fmlclient, --fml.forgeVersion, 36.1.23, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20210115.111550, --width, 854, --height, 480]
[25Jul2021 16:59:20.127] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 11.0.11 by Red Hat, Inc.
[25Jul2021 16:59:20.794] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust
[25Jul2021 16:59:20.898] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.2 Source=file:/home/badg