From f079578af48225e261ca51a6715c4e89ba89f703 Mon Sep 17 00:00:00 2001 From: Max Leske <250711+theseion@users.noreply.github.com> Date: Wed, 7 Aug 2024 20:03:27 +0200 Subject: [PATCH] chore: fetch enough commits for `git describe` to discover tags --- .github/workflows/lint.yaml | 12 +++--------- util/crs-rules-check/rules-check.py | 9 +++++---- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index ff71306374..b2d4180794 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -13,6 +13,9 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.2 + with: + # we want to use `git describe` to find the latest tag + fetch-depth: 50 - name: Lint Yaml uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c # v3.1.1 @@ -36,15 +39,6 @@ jobs: pip install secrules-parsing==${{ env.SECRULES_PARSING_VERSION }} secrules-parser -c --output-type github -f rules/*.conf - - name: "Fetch git tags" - run: | - git tag -l - git fetch --tags - - - name: "Show current tag" - run: | - git describe --tags - - name: "Check CRS formatting" run: | pip install --upgrade setuptools diff --git a/util/crs-rules-check/rules-check.py b/util/crs-rules-check/rules-check.py index 9b448b3d18..88a81d15d7 100755 --- a/util/crs-rules-check/rules-check.py +++ b/util/crs-rules-check/rules-check.py @@ -604,7 +604,7 @@ def check_tags(self, fname, tagslist): aidx += 1 def check_lowercase_ignorecase(self): - ruleid = 0 + ruleid = 0 for d in self.data: if d['type'].lower() == "secrule": if d['operator'] == "@rx": @@ -614,7 +614,7 @@ def check_lowercase_ignorecase(self): aidx = 0 # stores the index of current action while aidx < len(d['actions']): # read the action into 'a' - a = d['actions'][aidx] + a = d['actions'][aidx] if a['act_name'] == "id": ruleid = int(a['act_arg']) if a['act_name'] == 't': @@ -817,7 +817,9 @@ def generate_version_string(): v4.5.0-0-abcd01234 -> "4.5.0" """ result = subprocess.run(["git", "describe", "--tags"], capture_output=True, text=True) + print(result) version = re.sub("^v", "", result.stdout.strip()) + print(version) ver, commits = version.split("-")[0:2] if int(commits) > 0: version = ver.split(".") @@ -1074,7 +1076,7 @@ def generate_version_string(): a['title'] = "new unlisted tag" errmsgf(a) retval = 1 - ### check for t:lowercase in combination with (?i) in regex + ### check for t:lowercase in combination with (?i) in regex c.check_lowercase_ignorecase() if len(c.ignorecase) == 0: msg(" No t:lowercase and (?i) flag used.") @@ -1130,4 +1132,3 @@ def generate_version_string(): msg(" No unused TX variable") sys.exit(retval) -