Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit logging #6339

Merged
merged 62 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b3a740e
warehouse: Initial user, project event models
woodruffw Jul 31, 2019
da534a9
warehouse: Audit logs
woodruffw Aug 1, 2019
45a6e01
warehouse: Swap journal out for events on project history
woodruffw Aug 1, 2019
7d36766
warehouse: Initial project events
woodruffw Aug 1, 2019
2cd4cf2
warehouse: client_addr -> remote_addr
woodruffw Aug 1, 2019
201478c
warehouse: More user events
woodruffw Aug 2, 2019
2c7f74d
warehouse: Prefer event recording via IUserService
woodruffw Aug 2, 2019
1f17c29
warehouse: More account events
woodruffw Aug 2, 2019
264015e
warehouse: Move login recording into _login_user
woodruffw Aug 2, 2019
9e04ada
tests: Fix account view tests
woodruffw Aug 2, 2019
b2a3a1b
warehouse: Guard previous_primary_email
woodruffw Aug 2, 2019
dc1aa02
tests: Begin fixing management view tests
woodruffw Aug 2, 2019
d49a699
tests: Fix remaining management tests
woodruffw Aug 2, 2019
70e5c41
tests: Fix import order
woodruffw Aug 2, 2019
4e4c371
warehouse: Log API token creation to respective project events
woodruffw Aug 5, 2019
e27cb4f
warehouse: Add TODO
woodruffw Aug 5, 2019
5b3d7d7
warehouse: Simplify event tag names
woodruffw Aug 5, 2019
61aab56
tests: Update, fix tests
woodruffw Aug 5, 2019
6f8e00f
warehouse: Limit user event display to the last two weeks
woodruffw Aug 5, 2019
61cac1f
warehouse: orm_session -> object_session
woodruffw Aug 5, 2019
6f0b239
tests: Add recent_events test
woodruffw Aug 5, 2019
dabb656
warehouse: Enforce recent_events ordering
woodruffw Aug 5, 2019
d335e0e
warehouse: Expose account activity on admin page
woodruffw Aug 5, 2019
9600b85
warehouse: Expose project activity on admin page
woodruffw Aug 5, 2019
0901380
tests: Check events on all account views
woodruffw Aug 6, 2019
3f94f97
tests: Begin adding event checks to manage views
woodruffw Aug 6, 2019
a5a9309
tests: Complete event checks on manage views
woodruffw Aug 6, 2019
e154d6e
Merge branch 'master' into tob-audit-logging
woodruffw Aug 10, 2019
acca041
warehouse: Add project:api_token:removed
woodruffw Aug 13, 2019
055a5d7
tests: Update view tests
woodruffw Aug 13, 2019
71e5cc0
tests: Fill in coverage
woodruffw Aug 13, 2019
4fce5c6
Format account security logs
nlhkabu Aug 13, 2019
bce7160
Merge branch 'master' into tob-audit-logging
woodruffw Aug 13, 2019
7d26eba
warehouse: Use normalized name for project lookup
woodruffw Aug 13, 2019
d106810
warehouse: Update migration
woodruffw Aug 13, 2019
7e08308
tests: Update manage view tests
woodruffw Aug 13, 2019
5c5cc4e
Format project security logs
nlhkabu Aug 13, 2019
f767b1d
Fix linting
nlhkabu Aug 13, 2019
1f31a27
warehouse: Remove some whitespace
woodruffw Aug 13, 2019
6cc0d7d
warehouse: More project events
woodruffw Aug 14, 2019
ec08de9
warehouse: Rename tag
woodruffw Aug 14, 2019
caf3b94
warehouse: Fixup relationships, minimize kwargs
woodruffw Aug 14, 2019
6197cd6
warehouse: Update docstring
woodruffw Aug 14, 2019
83f6ce6
warehouse: record_event fixups, tweak migrations
woodruffw Aug 14, 2019
2a2af97
tests: Update tests
woodruffw Aug 14, 2019
930ce67
warehouse: Add fallthough conditions for tag rendering
woodruffw Aug 14, 2019
2047f4c
warehouse: Re-add journal table via new tab
woodruffw Aug 14, 2019
91b6a76
tests: Add route test, re-add journal tests
woodruffw Aug 14, 2019
d7f522e
Update manage project menu icon and text
nlhkabu Aug 15, 2019
8981df3
Add deprecation warning to project journals page
nlhkabu Aug 15, 2019
df909cf
Format project events (create project, release version, remove versio…
nlhkabu Aug 15, 2019
8d93cf5
Merge branch 'master' into tob-audit-logging
woodruffw Aug 15, 2019
93a953a
warehouse: Add username to more project events
woodruffw Aug 15, 2019
7c89047
tests: Update tests
woodruffw Aug 15, 2019
2759f48
warehouse: Display username against more project events
woodruffw Aug 15, 2019
1a17771
Merge branch 'master' into tob-audit-logging
woodruffw Aug 15, 2019
270db88
Merge branch 'master' into tob-audit-logging
woodruffw Aug 15, 2019
a2b1f0d
Update warehouse/templates/manage/account.html
woodruffw Aug 15, 2019
cf8431f
Update warehouse/templates/manage/account.html
woodruffw Aug 15, 2019
3be3996
Update warehouse/templates/manage/account.html
woodruffw Aug 15, 2019
09f1926
Update warehouse/templates/manage/history.html
woodruffw Aug 15, 2019
3cee212
Update warehouse/templates/manage/account.html
woodruffw Aug 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/common/db/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import factory
import factory.fuzzy

from warehouse.accounts.models import Email, User
from warehouse.accounts.models import Email, User, UserEvent

from .base import FuzzyEmail, WarehouseFactory

Expand All @@ -36,6 +36,13 @@ class Meta:
last_login = factory.fuzzy.FuzzyNaiveDateTime(datetime.datetime(2011, 1, 1))


class UserEventFactory(WarehouseFactory):
class Meta:
model = UserEvent

user = factory.SubFactory(User)


class EmailFactory(WarehouseFactory):
class Meta:
model = Email
Expand Down
8 changes: 8 additions & 0 deletions tests/common/db/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
File,
JournalEntry,
Project,
ProjectEvent,
Release,
Role,
)
Expand All @@ -43,6 +44,13 @@ class Meta:
name = factory.fuzzy.FuzzyText(length=12)


class ProjectEventFactory(WarehouseFactory):
class Meta:
model = ProjectEvent

project = factory.SubFactory(ProjectFactory)


class DescriptionFactory(WarehouseFactory):
class Meta:
model = Description
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/accounts/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import datetime

import pytest

from warehouse.accounts.models import Email, User, UserFactory

from ...common.db.accounts import (
EmailFactory as DBEmailFactory,
UserEventFactory as DBUserEventFactory,
UserFactory as DBUserFactory,
)

Expand Down Expand Up @@ -83,3 +86,18 @@ def test_query_by_email_when_not_primary(self, db_session):
result = db_session.query(User).filter(User.email == email.email).first()

assert result is None

def test_recent_events(self, db_session):
user = DBUserFactory.create()
recent_event = DBUserEventFactory(user=user, tag="foo", ip_address="0.0.0.0")
stale_event = DBUserEventFactory(
user=user,
tag="bar",
ip_address="0.0.0.0",
time=datetime.datetime.now() - datetime.timedelta(days=15),
)

assert len(user.events) == 2
assert len(user.recent_events) == 1
assert user.events == [recent_event, stale_event]
assert user.recent_events == [recent_event]