Skip to content

Commit

Permalink
[Backport 4.4-7.16] Bump Wazuh and platform versions for v4.4.1 (#5349)
Browse files Browse the repository at this point in the history
Bump Wazuh and platform versions for v4.4.1 (#5347)

* Prepare the app for Wazuh 4.4.1

* Revert dry-run option from the tagging tool

* Revert dry-run option from the tagging tool

* Bump node version to 14.20.1

Fix the tag script

* Fix tag.py again

* Revert changes to .nvmrc

(cherry picked from commit d69d840)
  • Loading branch information
AlexRuiz7 authored Mar 31, 2023
1 parent 87c9668 commit fd994c8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 18 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ This plugin for Kibana allows you to visualize and analyze Wazuh alerts stored i

## Requisites

- Wazuh HIDS 4.4.0
- Kibana 7.16.0
- Elasticsearch 7.16.0
- Wazuh HIDS 4.4.1
- Kibana 7.16.x or 7.17.x
- Elasticsearch 7.16.x or 7.17.x

## Installation

Expand Down
6 changes: 2 additions & 4 deletions common/api-info/security-actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@
"DELETE /agents/{agent_id}/group/{group_id}",
"PUT /agents/{agent_id}/group/{group_id}",
"DELETE /agents/group",
"PUT /agents/group",
"DELETE /groups"
"PUT /agents/group"
]
},
"group:modify_assignments": {
Expand All @@ -134,8 +133,7 @@
"DELETE /agents/{agent_id}/group/{group_id}",
"PUT /agents/{agent_id}/group/{group_id}",
"DELETE /agents/group",
"PUT /agents/group",
"DELETE /groups"
"PUT /agents/group"
]
},
"agent:restart": {
Expand Down
58 changes: 47 additions & 11 deletions scripts/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,30 @@
import subprocess

# ==================== CONFIGURATION ==================== #
# Fill the variables below with the desired values
#
# Values to modify:
# - version
# - revision
# - stage
# - version - sent to the package.json
# - revision - sent to the package.json
# - stage - sent to the package.json
# - tag_suffix - used by the tag generation
# - supported_versions & kbn_versions ONLY IF NEEDED (e.g. new Kibana version)
# ======================================================= #

# Wazuh version: major.minor.patch
version = '4.4.0'
version = '4.4.1'
# App's revision number (previous rev + 1)
revision = '06'
revision = '00'
# One of 'pre-alpha', 'alpha', 'beta', 'release-candidate', 'stable'
stage = 'stable'

stage = 'release-candidate'
# Tag suffix. Usually set to stage + stage iteration.
tag_suffix = 'rc1'

# ================================================ #
# Constants and global variables #
# ================================================ #
LOG_FILE = 'output.log'
TAGS_FILE = 'tags.log'
# Global variable. Will be set later
branch = None
minor = ".".join(version.split('.')[:2])
Expand All @@ -41,16 +51,31 @@
},
'Wazuh Dashboard': {
'branch': f'{minor}-2.4-wzd',
'versions': ['2.4.1']
'versions': ['2.6.0']
}
}

# ================================================ #
# Functions #
# ================================================ #

def require_confirmation():
"""Ask for confirmation before running the script."""
print('WARNING! This script will commit and push the tags to the remote '
+ 'repository, deleting any unpushed changes.')
confirmation = input('Do you want to continue? [y/N] ')

if confirmation.lower() != 'y':
logging.info('Aborting...')
exit(0)


def get_git_revision_short_hash() -> str:
return subprocess.check_output(['git', 'rev-parse', '--short', branch]).decode('ascii').strip()


def update_package_json(v: str) -> tuple:
"""Update package.json with the new version and revision."""
logging.info(f'Updating package.json')
data, success = {}, True

Expand All @@ -74,18 +99,20 @@ def update_package_json(v: str) -> tuple:


def setup():
"""Sync the repo."""
logging.info(
f'Switching to branch "{branch}" and removing outdated tags...')
os.system(f'git checkout {branch}')
os.system('git fetch --prune --prune-tags')


def main(platform: str, versions: list):
"""Main function."""
for v in versions:
if stage == 'stable':
tag = f'v{version}-{v}'
else:
tag = f'v{version}-{v}-{stage}'
tag = f'v{version}-{v}-{tag_suffix}'
logging.info(f'Generating tag "{tag}"')
update_package_json(v)
os.system(f'git commit -am "Bump {tag}"')
Expand All @@ -95,20 +122,29 @@ def main(platform: str, versions: list):
os.system(f'git push origin {tag}')
# Undo latest commit
os.system(f'git reset --hard origin/{branch}')

# Save created tags to file
os.system(f'git tag | grep -P -i "^v{version}-.*-{stage}" > tags.txt')
os.system(f'git tag | grep -P -i "^v{version}-.*-{tag_suffix}" > {TAGS_FILE}')

# ================================================ #
# Main program #
# ================================================ #

if __name__ == '__main__':
logging.basicConfig(
filename='output.log',
filename=LOG_FILE,
level=logging.INFO,
format='%(asctime)s %(message)s'
)
logging.info(
f'Wazuh version is "{version}". App revision is "{revision}". Stage is "{stage}"')
require_confirmation()

for platform_name, platform_data in supported_versions.items():
branch, versions = platform_data['branch'], platform_data['versions']
setup()
main(platform_name, versions)


print(f'\nCOMPLETED. \nCheck {LOG_FILE} for more details.')
print(f'Tags are stored in {TAGS_FILE}')

0 comments on commit fd994c8

Please sign in to comment.