Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for highlighting this
I’ve restored the README to its original state. I’ll add the Update Checker documentation under the Installation section in the docs repository (as suggested) via a separate PR.

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
97 changes: 97 additions & 0 deletions api_app/core/update_checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
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:
logger.warning("UPDATE_CHECK_URL not configured")
return None

try:
resp = requests.get(
update_url,
headers={"User-Agent": "IntelOwl-Update-Checker"},
timeout=5,
)
resp.raise_for_status()

data = resp.json()
tag = data.get("tag_name")
if not tag:
logger.warning("release response missing tag_name")
return None

# remove optional 'v' prefix
return tag.lstrip("v")

except requests.RequestException as exc:
logger.error(f"update check failed: {exc}")
return None
except ValueError:
logger.error("invalid JSON in update response")
return None


def check_for_update():
"""
Compare the running IntelOwl version with the latest available one
and log a warning if a newer version exists.
"""
current_version_str = getattr(settings, "INTEL_OWL_VERSION", None)
latest_str = fetch_latest_version()

if not current_version_str:
logger.warning("INTEL_OWL_VERSION setting missing")
return

if not latest_str:
return # fetch logged any errors

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:
# fallback string compare if parsing failed
if latest_str != current_version_str:
logger.warning(
f"Update available: {latest_str} "
f"(current: {current_version_str})"
)
return

if latest > current:
logger.warning(
f"New IntelOwl version available: {latest_str} "
f"(current: {current_version_str})"
)
elif latest < current:
logger.info(
f"Local version ahead of release: "
f"{current_version_str} > {latest_str}"
)
else:
logger.info(f"IntelOwl version up to date ({current_version_str})")
9 changes: 9 additions & 0 deletions api_app/management/commands/check_updates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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):
check_for_update()
self.stdout.write(self.style.SUCCESS("Update check completed"))
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