mirror of
https://github.com/mblanke/ThreatHunt.git
synced 2026-03-01 14:00:20 -05:00
Fix code review issues: update datetime.utcnow() to datetime.now(timezone.utc) and fix Docker configs
Co-authored-by: mblanke <9078342+mblanke@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta, timezone
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from jose import JWTError, jwt
|
from jose import JWTError, jwt
|
||||||
from passlib.context import CryptContext
|
from passlib.context import CryptContext
|
||||||
@@ -32,9 +32,9 @@ def create_access_token(data: dict, expires_delta: Optional[timedelta] = None) -
|
|||||||
"""
|
"""
|
||||||
to_encode = data.copy()
|
to_encode = data.copy()
|
||||||
if expires_delta:
|
if expires_delta:
|
||||||
expire = datetime.utcnow() + expires_delta
|
expire = datetime.now(timezone.utc) + expires_delta
|
||||||
else:
|
else:
|
||||||
expire = datetime.utcnow() + timedelta(minutes=settings.access_token_expire_minutes)
|
expire = datetime.now(timezone.utc) + timedelta(minutes=settings.access_token_expire_minutes)
|
||||||
|
|
||||||
to_encode.update({"exp": expire})
|
to_encode.update({"exp": expire})
|
||||||
encoded_jwt = jwt.encode(to_encode, settings.secret_key, algorithm=settings.algorithm)
|
encoded_jwt = jwt.encode(to_encode, settings.secret_key, algorithm=settings.algorithm)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Text, JSON
|
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Text, JSON
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from app.core.database import Base
|
from app.core.database import Base
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ class Artifact(Base):
|
|||||||
description = Column(Text, nullable=True)
|
description = Column(Text, nullable=True)
|
||||||
case_id = Column(Integer, ForeignKey("cases.id"), nullable=True)
|
case_id = Column(Integer, ForeignKey("cases.id"), nullable=True)
|
||||||
artifact_metadata = Column(JSON, nullable=True)
|
artifact_metadata = Column(JSON, nullable=True)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
||||||
|
|
||||||
# Relationships
|
# Relationships
|
||||||
case = relationship("Case", back_populates="artifacts")
|
case = relationship("Case", back_populates="artifacts")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Text
|
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Text
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from app.core.database import Base
|
from app.core.database import Base
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ class Case(Base):
|
|||||||
status = Column(String, default="open", nullable=False) # open, closed, investigating
|
status = Column(String, default="open", nullable=False) # open, closed, investigating
|
||||||
severity = Column(String, nullable=True) # low, medium, high, critical
|
severity = Column(String, nullable=True) # low, medium, high, critical
|
||||||
tenant_id = Column(Integer, ForeignKey("tenants.id"), nullable=False)
|
tenant_id = Column(Integer, ForeignKey("tenants.id"), nullable=False)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
||||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
updated_at = Column(DateTime, default=lambda: datetime.now(timezone.utc), onupdate=lambda: datetime.now(timezone.utc))
|
||||||
|
|
||||||
# Relationships
|
# Relationships
|
||||||
tenant = relationship("Tenant", back_populates="cases")
|
tenant = relationship("Tenant", back_populates="cases")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, JSON
|
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, JSON
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from app.core.database import Base
|
from app.core.database import Base
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ class Host(Base):
|
|||||||
os = Column(String, nullable=True)
|
os = Column(String, nullable=True)
|
||||||
tenant_id = Column(Integer, ForeignKey("tenants.id"), nullable=False)
|
tenant_id = Column(Integer, ForeignKey("tenants.id"), nullable=False)
|
||||||
host_metadata = Column(JSON, nullable=True)
|
host_metadata = Column(JSON, nullable=True)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
||||||
last_seen = Column(DateTime, default=datetime.utcnow)
|
last_seen = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
||||||
|
|
||||||
# Relationships
|
# Relationships
|
||||||
tenant = relationship("Tenant", back_populates="hosts")
|
tenant = relationship("Tenant", back_populates="hosts")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from sqlalchemy import Column, Integer, String, DateTime
|
from sqlalchemy import Column, Integer, String, DateTime
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from app.core.database import Base
|
from app.core.database import Base
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ class Tenant(Base):
|
|||||||
id = Column(Integer, primary_key=True, index=True)
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
name = Column(String, unique=True, index=True, nullable=False)
|
name = Column(String, unique=True, index=True, nullable=False)
|
||||||
description = Column(String, nullable=True)
|
description = Column(String, nullable=True)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
||||||
|
|
||||||
# Relationships
|
# Relationships
|
||||||
users = relationship("User", back_populates="tenant")
|
users = relationship("User", back_populates="tenant")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Boolean
|
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Boolean
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from app.core.database import Base
|
from app.core.database import Base
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ class User(Base):
|
|||||||
role = Column(String, default="user", nullable=False) # user, admin
|
role = Column(String, default="user", nullable=False) # user, admin
|
||||||
tenant_id = Column(Integer, ForeignKey("tenants.id"), nullable=False)
|
tenant_id = Column(Integer, ForeignKey("tenants.id"), nullable=False)
|
||||||
is_active = Column(Boolean, default=True, nullable=False)
|
is_active = Column(Boolean, default=True, nullable=False)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
||||||
|
|
||||||
# Relationships
|
# Relationships
|
||||||
tenant = relationship("Tenant", back_populates="users")
|
tenant = relationship("Tenant", back_populates="users")
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ services:
|
|||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
volumes:
|
volumes:
|
||||||
- ./backend:/app
|
- ./backend:/app
|
||||||
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
|
command: sh -c "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload"
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
build:
|
build:
|
||||||
|
|||||||
8
frontend/.dockerignore
Normal file
8
frontend/.dockerignore
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
node_modules
|
||||||
|
npm-debug.log
|
||||||
|
build
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
README.md
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
@@ -3,7 +3,8 @@ FROM node:18-alpine
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package files
|
# Copy package files
|
||||||
COPY package*.json ./
|
COPY package.json ./
|
||||||
|
COPY package-lock.json* ./
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|||||||
Reference in New Issue
Block a user