Repository: oscal-compass/compliance-trestle (python)

Issue:
Trestle author -tv flag doesn't enforce the version format (e.g. 0.0.1) correctly
## Describe the bug
Invalid version formats (e.g. 1a2b3) are not captured when using the `trestle author header -tv` command. This behavior is due to the . character is not escaped properly in `is_valid_version()` under `template_versioning.py`.

A fix might look like this:
<img width="406" alt="image" src="https://github.com/oscal-compass/compliance-trestle/assets/78010183/685f98cf-8a83-4f0f-8b41-8e2c60ba622e">


## To Reproduce

Steps to reproduce the behavior:
` trestle author headers setup -tn my_task -tv 1a2b3`

## Expected behavior

The program should throw an error, and the task folder should not be created.

## Screenshots / Logs.
After executing the above command:
<img width="303" alt="image" src="https://github.com/oscal-compass/compliance-trestle/assets/78010183/07754145-6e73-4b0b-bb38-05576d01d559">

## Environment

- OS: \[e.g. iOS\]
- Python version:
- Installed packages:


Pull request description:
fix: update the regex of template version to prevent invalid version format
## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Hot fix (emergency fix and release)
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Documentation (change which affects the documentation site)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Release (`develop` -> `main`)

## Quality assurance (all should be covered).

- [x] My code follows the code style of this project.
- [x] Documentation for my change is up to date?
- [x] My PR meets testing requirements.
- [x] All new and existing tests passed.
- [x] All commits are signed-off.

## Summary
Resolved #1586 
Correct the regex of the template version to prevent an invalid version format
## Key links:

# Before you merge

- Ensure it is a 'squash commit' if not a release.
- Ensure CI is currently passing
- Check sonar. If you are working for a fork a maintainer will reach out, if required.


Patch:
diff --git a/trestle/core/commands/author/versioning/template_versioning.py b/trestle/core/commands/author/versioning/template_versioning.py
index e9c954d8..43f52483 100644
--- a/trestle/core/commands/author/versioning/template_versioning.py
+++ b/trestle/core/commands/author/versioning/template_versioning.py
@@ -212,7 +212,7 @@ class TemplateVersioning:
             return True  # we can have empty version
         if template_version == '0.0.0':
             return False
-        version_regex = r'^[0-9]+.[0-9]+.[0-9]+$'
+        version_regex = r'^[0-9]+\.[0-9]+\.[0-9]+$'
         pattern = re.compile(version_regex)
         if pattern.search(template_version):
             return True


Test patch:
diff --git a/tests/trestle/core/commands/author/versioning/template_versioning_test.py b/tests/trestle/core/commands/author/versioning/template_versioning_test.py
index 8d7fbb10..10f04bb2 100644
--- a/tests/trestle/core/commands/author/versioning/template_versioning_test.py
+++ b/tests/trestle/core/commands/author/versioning/template_versioning_test.py
@@ -222,6 +222,7 @@ def test_valid_version() -> None:
     assert not TemplateVersioning.is_valid_version('0.1')
     assert not TemplateVersioning.is_valid_version('1')
     assert not TemplateVersioning.is_valid_version('0.0.0.1')
+    assert not TemplateVersioning.is_valid_version('0a0b1')
 
 
 def test_empty_folder_is_not_created(tmp_path: pathlib.Path) -> None: