feat: history log setup #101

Closed
alejandrosame wants to merge 1 commit from feat/history-log into main
alejandrosame commented 2023-12-11 04:20:53 +00:00 (Migrated from github.com)

The history log is implemented with the package 'django-pghistory', which uses pg triggers.

The summary of changes is as follows:

  • Changed DATABASE_URL to signal the dependency on postgresql. Migrations won't work anymore with sqlite.
  • Added python packages 'django-pghistory' and 'django-pgtrigger' (a dependency of the former inside django app).
  • A basic NixpkgsIssue snapshot model, tracking cve, derivations and statusfields.

This constitutes the building blocks for all activity log we want to register.

The history log is implemented with the package 'django-pghistory', which uses pg triggers. The summary of changes is as follows: - Changed DATABASE_URL to signal the dependency on postgresql. Migrations won't work anymore with sqlite. - Added python packages 'django-pghistory' and 'django-pgtrigger' (a dependency of the former inside django app). - A basic NixpkgsIssue snapshot model, tracking `cve`, `derivations` and `status`fields. This constitutes the building blocks for all activity log we want to register.
fricklerhandwerk (Migrated from github.com) reviewed 2023-12-11 04:20:53 +00:00
fricklerhandwerk (Migrated from github.com) requested changes 2023-12-11 13:41:58 +00:00
fricklerhandwerk (Migrated from github.com) left a comment

This now requires a substantial rebase

This now requires a substantial rebase
fricklerhandwerk (Migrated from github.com) commented 2023-12-11 09:57:08 +00:00

The prefix should't be needed with #86

The prefix should't be needed with #86
fricklerhandwerk (Migrated from github.com) commented 2023-12-11 09:58:13 +00:00
{ lib, fetchFromGitHub, buildPythonPackage, django_4, poetry-core }:

buildPythonPackage rec {
  pname = "django-pghistory";
  version = "3.1.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "Opus10";
    repo = "django-pghistory";
    rev = "${version}";
    hash = "sha256-+/JmbKd4Qe+hR0UtBg4wm682pss9WCQhe4xE5UZDIik=";
  };

  propagatedBuildInputs = [ django_4 poetry-core ];

Also with #86, and similar for the other package

```suggestion { lib, fetchFromGitHub, buildPythonPackage, django_4, poetry-core }: buildPythonPackage rec { pname = "django-pghistory"; version = "3.1.0"; pyproject = true; src = fetchFromGitHub { owner = "Opus10"; repo = "django-pghistory"; rev = "${version}"; hash = "sha256-+/JmbKd4Qe+hR0UtBg4wm682pss9WCQhe4xE5UZDIik="; }; propagatedBuildInputs = [ django_4 poetry-core ]; ``` Also with #86, and similar for the other package
fricklerhandwerk (Migrated from github.com) commented 2023-12-11 10:06:26 +00:00
https://github.com/Nix-Security-WG/nix-security-tracker/pull/66/files#diff-42e2af48200a6b6083704ad7f3ceadc6138e7cfe19200e80f0229a035e18edc6R182 @RaitoBezarius Is the linked comment correct?
fricklerhandwerk (Migrated from github.com) reviewed 2023-12-11 13:45:42 +00:00
fricklerhandwerk (Migrated from github.com) commented 2023-12-11 13:45:09 +00:00

We don't want to snapshot everything, as that will require a lot of churn and diffing the snapshots and such. Also the DB can be expected to be large. What we need to track already:

  • status changed
  • description snapshots
  • cve added/removed
  • derivation added/removed

All this indexed by user.

We don't want to snapshot everything, as that will require a lot of churn and diffing the snapshots and such. Also the DB can be expected to be large. What we need to track already: - status changed - description snapshots - cve added/removed - derivation added/removed All this indexed by user.
alejandrosame (Migrated from github.com) reviewed 2023-12-11 15:54:32 +00:00
alejandrosame (Migrated from github.com) commented 2023-12-11 15:54:32 +00:00

applied

applied
alejandrosame (Migrated from github.com) reviewed 2023-12-11 15:54:44 +00:00
alejandrosame (Migrated from github.com) commented 2023-12-11 15:54:44 +00:00

applied

applied
alejandrosame (Migrated from github.com) reviewed 2023-12-11 15:56:46 +00:00
alejandrosame (Migrated from github.com) commented 2023-12-11 15:56:46 +00:00

Assuming you are referring to the placement of this settings before the user settings logic, applied already.

Assuming you are referring to the placement of this settings before the user settings logic, applied already.
alejandrosame (Migrated from github.com) reviewed 2023-12-11 16:22:33 +00:00
alejandrosame (Migrated from github.com) commented 2023-12-11 16:22:33 +00:00

I added tracking per field. pghistory already diffs changes, instead of snapshotting the whole row.

For the CVE and derivation addition/removal I'll need to have clear the representation to contruct the proper query, for now it tracks the field directly in the NixpkgsIssue model.

I added tracking per field. pghistory already diffs changes, instead of snapshotting the whole row. For the CVE and derivation addition/removal I'll need to have clear the representation to contruct the proper query, for now it tracks the field directly in the NixpkgsIssue model.
alejandrosame commented 2023-12-11 16:27:30 +00:00 (Migrated from github.com)

There are migration errors in main that prevent me from finishing a proper rebase. They should be fixed there first so I can rebase again.

There are migration errors in main that prevent me from finishing a proper rebase. They should be fixed there first so I can rebase again.
fricklerhandwerk (Migrated from github.com) reviewed 2023-12-11 17:34:06 +00:00
@ -479,6 +302,11 @@ class IssueStatus(models.TextChoices):
WONTFIX = "W", _("wontfix")
fricklerhandwerk (Migrated from github.com) commented 2023-12-11 17:34:06 +00:00
    fields=["cve", "derivations", "status"],

We should defer the decision on how to deal with description changes to later.

```suggestion fields=["cve", "derivations", "status"], ``` We should defer the decision on how to deal with description changes to later.
alejandrosame commented 2023-12-12 16:33:42 +00:00 (Migrated from github.com)

This PR is in a working state again.

After much fiddling with the default admin views of pghistory, I don't find them very usable. Taking this as starting point, I'll now create an Activity Log app to put there usable custom views of the different tables tracking the changes we want to summarise.

This PR is in a working state again. After much fiddling with the default admin views of `pghistory`, I don't find them very usable. Taking this as starting point, I'll now create an `Activity Log` app to put there usable custom views of the different tables tracking the changes we want to summarise.
alejandrosame commented 2024-11-28 03:04:31 +00:00 (Migrated from github.com)

Implemented in #366

Implemented in #366

Pull request closed

Sign in to join this conversation.
No description provided.