Bug#1041792: httpie: phones home for version check

2023-08-02 Thread ss0buh+5z7qu6hu1fgzw
Package: httpie
Followup-For: Bug #1041792
Control: tags -1 patch

quick patch attached
>From 3ce3cacb8d3f7beff8d684a088ac4ecc016cc9c1 Mon Sep 17 00:00:00 2001
From: Your Name 
Date: Wed, 2 Aug 2023 11:23:38 +
Subject: [PATCH] disable updates

---
 httpie/core.py|   2 -
 httpie/internal/daemon_runner.py  |   2 -
 httpie/internal/update_warnings.py| 171 ---
 httpie/manager/tasks/__init__.py  |   2 -
 httpie/manager/tasks/check_updates.py |  10 --
 tests/test_update_warnings.py | 237 --
 6 files changed, 424 deletions(-)
 delete mode 100644 httpie/internal/update_warnings.py
 delete mode 100644 httpie/manager/tasks/check_updates.py
 delete mode 100644 tests/test_update_warnings.py

diff --git a/httpie/core.py b/httpie/core.py
index d0c26dc..0755e6d 100644
--- a/httpie/core.py
+++ b/httpie/core.py
@@ -24,7 +24,6 @@ from .output.writer import write_message, write_stream, 
write_raw_data, MESSAGE_
 from .plugins.registry import plugin_manager
 from .status import ExitStatus, http_status_to_exit_status
 from .utils import unwrap_context
-from .internal.update_warnings import check_updates
 from .internal.daemon_runner import is_daemon_mode, run_daemon_task
 
 
@@ -95,7 +94,6 @@ def raw_main(
 raise
 exit_status = ExitStatus.ERROR
 else:
-check_updates(env)
 try:
 exit_status = main_program(
 args=parsed_args,
diff --git a/httpie/internal/daemon_runner.py b/httpie/internal/daemon_runner.py
index ec20b50..b2d3fb1 100644
--- a/httpie/internal/daemon_runner.py
+++ b/httpie/internal/daemon_runner.py
@@ -3,7 +3,6 @@ from contextlib import redirect_stderr, redirect_stdout
 from typing import List
 
 from httpie.context import Environment
-from httpie.internal.update_warnings import _fetch_updates, 
_get_suppress_context
 from httpie.status import ExitStatus
 
 STATUS_FILE = '.httpie-test-daemon-status'
@@ -23,7 +22,6 @@ def _check_status(env):
 
 DAEMONIZED_TASKS = {
 'check_status': _check_status,
-'fetch_updates': _fetch_updates,
 }
 
 
diff --git a/httpie/internal/update_warnings.py 
b/httpie/internal/update_warnings.py
deleted file mode 100644
index a4b80d4..000
--- a/httpie/internal/update_warnings.py
+++ /dev/null
@@ -1,171 +0,0 @@
-import json
-from contextlib import nullcontext, suppress
-from datetime import datetime, timedelta
-from pathlib import Path
-from typing import Any, Optional, Callable
-
-import requests
-
-import httpie
-from httpie.context import Environment, LogLevel
-from httpie.internal.__build_channel__ import BUILD_CHANNEL
-from httpie.internal.daemons import spawn_daemon
-from httpie.utils import is_version_greater, open_with_lockfile
-
-# Automatically updated package version index.
-PACKAGE_INDEX_LINK = 'https://packages.httpie.io/latest.json'
-
-FETCH_INTERVAL = timedelta(weeks=2)
-WARN_INTERVAL = timedelta(weeks=1)
-
-UPDATE_MESSAGE_FORMAT = """\
-A new HTTPie release ({last_released_version}) is available.
-To see how you can update, please visit 
https://httpie.io/docs/cli/{installation_method}
-"""
-
-ALREADY_UP_TO_DATE_MESSAGE = """\
-You are already up-to-date.
-"""
-
-
-def _read_data_error_free(file: Path) -> Any:
-# If the file is broken / non-existent, ignore it.
-try:
-with open(file) as stream:
-return json.load(stream)
-except (ValueError, OSError):
-return {}
-
-
-def _fetch_updates(env: Environment) -> str:
-file = env.config.version_info_file
-data = _read_data_error_free(file)
-
-response = requests.get(PACKAGE_INDEX_LINK, verify=False)
-response.raise_for_status()
-
-data.setdefault('last_warned_date', None)
-data['last_fetched_date'] = datetime.now().isoformat()
-data['last_released_versions'] = response.json()
-
-with open_with_lockfile(file, 'w') as stream:
-json.dump(data, stream)
-
-
-def fetch_updates(env: Environment, lazy: bool = True):
-if lazy:
-spawn_daemon('fetch_updates')
-else:
-_fetch_updates(env)
-
-
-def maybe_fetch_updates(env: Environment) -> None:
-if env.config.get('disable_update_warnings'):
-return None
-
-data = _read_data_error_free(env.config.version_info_file)
-
-if data:
-current_date = datetime.now()
-last_fetched_date = datetime.fromisoformat(data['last_fetched_date'])
-earliest_fetch_date = last_fetched_date + FETCH_INTERVAL
-if current_date < earliest_fetch_date:
-return None
-
-fetch_updates(env)
-
-
-def _get_suppress_context(env: Environment) -> Any:
-"""Return a context manager that suppress
-all possible errors.
-
-Note: if you have set the developer_mode=True in
-your config, then it will show all errors for easier
-debugging."""
-if env.config.developer_mode:
-return nullcontext()
-else:
-return suppress(BaseException)
-
-
-def _update_checker(
-  

Bug#1041792: httpie: phones home for version check

2023-07-23 Thread ss0buh+5z7qu6hu1fgzw
Package: httpie
Followup-For: Bug #1041792

Further testing with help of people on IRC revealed the following information:

If you simply install httpie, and don't create any config directories, it will 
perform the version check every single time you run httpie.

If you create the directory ~/.config/httpie/ then httpie will download the 
file https://packages.httpie.io/latest.json and save it in 
~/.config/httpie/version_info.json

If you delete ~/.config/httpie/version_info.json and create the file 
~/.config/httpie/config.json with this content:

{
  "disable_update_warnings": true
}

then the version checks stop and ~/.config/httpie/version_info.json stops being 
created. This is poorly documented upstream.

I don't know if it is a permanent solution, or if it only temporarily stops 
this. I'm providing this as a workaround before it is fixed in the debian 
package.

In any case, this behavior should be patched out in httpie as distributed by 
debian.



Bug#1041792: httpie: phones home for version check

2023-07-23 Thread ss0buh+5z7qu6hu1fgzw
Package: httpie
Version: 3.2.1-1
Severity: serious

Dear Maintainer,

httpie makes a request to packages.httpie.io every time you start it. It does 
this presumably to check for a newer version, which is irrelevant in debian. It 
also smells like a policy violation, though I didn't find an exact paragraph 
that covers this.

This can be seen in the source code here:
https://sources.debian.org/src/httpie/3.2.1-1/httpie/internal/update_warnings.py/?hl=16#L16

Upstream has some documentation here:
https://httpie.io/docs/cli/update-warnings

Please remove this update check, not only is it irrelevant in debian, but it 
also causes a mess in logs due to unintended DNS requests.
thanks


-- System Information:
Debian Release: 12.1
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.1.0-10-amd64 (SMP w/1 CPU thread; PREEMPT)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages httpie depends on:
ii  python3 3.11.2-1+b1
ii  python3-charset-normalizer  3.0.1-2
ii  python3-defusedxml  0.7.1-2
ii  python3-multidict   6.0.4-1+b1
ii  python3-pip 23.0.1+dfsg-1
ii  python3-pkg-resources   66.1.1-1
ii  python3-pygments2.14.0+dfsg-1
ii  python3-requests2.28.1+dfsg-1
ii  python3-requests-toolbelt   0.10.1-1
ii  python3-rich13.3.1-1
ii  python3-socks   1.7.1+dfsg-1

httpie recommends no packages.

httpie suggests no packages.

-- no debconf information