diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index ff71306374..88f688d18a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -13,6 +13,10 @@ 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 + fetch-tags: true - name: Lint Yaml uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c # v3.1.1 @@ -36,15 +40,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..2b7ba5cc0d 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': @@ -816,8 +816,10 @@ def generate_version_string(): v4.5.0-6-g872a90ab -> "4.6.0-dev" v4.5.0-0-abcd01234 -> "4.5.0" """ - result = subprocess.run(["git", "describe", "--tags"], capture_output=True, text=True) + result = subprocess.run(["git", "describe", "--tags", "--match", "v*.*.*", "main"], 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) -