Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ It provides:
We try hard to keep our documentation well written, easy to understand and always updated.
All info about installation, usage, configuration and contribution can be found [here](https://intelowlproject.github.io/docs/)


### Update Checker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot pollute the ReadMe with this content. Please remove this line and add this instead with a new PR in the Installation section: https://github.com/intelowlproject/docs/blob/main/docs/IntelOwl/installation.md

A new management command is available to check whether the running
IntelOwl instance is behind the latest published release.
This is useful for administrators who want to be notified when an upgrade is available.
#### Run manually
```bash
python manage.py check_updates
```
The command fetches the latest release tag from the configured source
and compares it to the local version.
#### Configuration
Defaults can be overridden in settings:
```python
REACT_APP_INTELOWL_VERSION = "6.4.0" # local version string
UPDATE_CHECK_URL = "https://api.github.com/repos/intelowlproject/IntelOwl/releases/latest"
```
No updates are installed automatically; the command only logs whether a new version is available. For periodic checks, you can schedule this command using cron or another job scheduler.


### Publications and Media

To know more about the project and its growth over time, you may be interested in reading [the official blog posts and/or videos about the project by clicking on this link](https://intelowlproject.github.io/docs/IntelOwl/introduction/#publications-and-media)
Expand Down
98 changes: 98 additions & 0 deletions api_app/core/update_checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import logging

import requests
from django.conf import settings

logger = logging.getLogger(__name__)


def normalize_version(v):
"""
Convert '1.2.3' → (1, 2, 3) so versions can be compared.
Stops at the first non-numeric part.
"""
parts = []
for x in v.split("."):
if x.isdigit():
parts.append(int(x))
else:
break
return tuple(parts)


def fetch_latest_version():
"""
Fetch the latest IntelOwl version string from the update URL.
Returns a version string without any leading 'v', or None on error.
"""
update_url = getattr(settings, "UPDATE_CHECK_URL", None)

if not update_url:
return None, "UPDATE_CHECK_URL not configured"

try:
resp = requests.get(
update_url,
headers={"User-Agent": "IntelOwl-Update-Checker"},
timeout=5,
)
resp.raise_for_status()
except requests.RequestException as exc:
logger.error(f"update check failed: {exc}")
return None, "Failed to fetch release information"

try:
data = resp.json()
except ValueError:
logger.error("invalid JSON in update response")
return None, "Invalid response from update server"

tag = data.get("tag_name")
if not tag:
return None, "Release response missing tag_name"

return tag.lstrip("v"), None


def check_for_update():
"""
Compare the running IntelOwl version with the latest available one.

Returns:
(success: bool, message: str)
"""
current_version_str = getattr(settings, "INTEL_OWL_VERSION", None)
if not current_version_str:
return False, "INTEL_OWL_VERSION setting missing"

latest_str, error = fetch_latest_version()
if error:
return False, error

current_version_str = str(current_version_str).lstrip("v")

current = normalize_version(current_version_str)
latest = normalize_version(latest_str)

if not current or not latest:
if latest_str != current_version_str:
return (
True,
f"Update available: {latest_str} (current: {current_version_str})",
)
return True, f"IntelOwl version up to date ({current_version_str})"

if latest > current:
return (
True,
f"New IntelOwl version available: {latest_str} "
f"(current: {current_version_str})",
)

if latest < current:
return (
True,
f"Local version ahead of release: " f"{current_version_str} > {latest_str}",
)

return True, f"IntelOwl version up to date ({current_version_str})"
15 changes: 15 additions & 0 deletions api_app/management/commands/check_updates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.core.management.base import BaseCommand

from api_app.core.update_checker import check_for_update


class Command(BaseCommand):
help = "Check for newer IntelOwl releases"

def handle(self, *args, **options):
success, message = check_for_update()

if success:
self.stdout.write(self.style.SUCCESS(message))
else:
self.stdout.write(self.style.ERROR(message))
7 changes: 7 additions & 0 deletions intel_owl/settings/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@
GIT_SSH_SCRIPT_PATH = (
PROJECT_LOCATION / "api_app" / "analyzers_manager" / "ssh_gitpython.sh"
)

# Update checker settings
UPDATE_CHECK_URL = get_secret(
"UPDATE_CHECK_URL",
"https://api.github.com/repos/intelowlproject/IntelOwl/releases/latest",
)
INTEL_OWL_VERSION = VERSION
Loading