docs: record threat model and security evidence
CI / verify (pull_request) Failing after 8m2s

This commit is contained in:
2026-11-06 21:26:36 +03:00
parent 5ac64f51fa
commit d6e91c0c22
36 changed files with 667 additions and 139 deletions
+2 -2
View File
@@ -28,7 +28,7 @@ import (
"gitea.privcloud.tech/dizi/mtusi2026lab7/internal/telemetry"
)
func RunDispatcher(logger *slog.Logger) error {
func RunDispatcher() error {
settings, err := config.LoadDispatcher()
if err != nil {
return err
@@ -87,7 +87,7 @@ func RunDispatcher(logger *slog.Logger) error {
)
}
func RunWorker(logger *slog.Logger) error {
func RunWorker() error {
settings, err := config.LoadWorker()
if err != nil {
return err
+1 -2
View File
@@ -5,7 +5,6 @@ import (
"crypto/tls"
"errors"
"fmt"
"log/slog"
"net"
"net/http"
"os"
@@ -30,7 +29,7 @@ type serverResult struct {
err error
}
func RunServer(logger *slog.Logger) error {
func RunServer() error {
settings, err := config.LoadServer()
if err != nil {
return err
+1 -1
View File
@@ -74,7 +74,7 @@ func loadSecretFile(values *viper.Viper, path string) error {
if err != nil {
return fmt.Errorf("open messenger secrets: %w", err)
}
defer file.Close()
defer func() { _ = file.Close() }()
decoder := json.NewDecoder(io.LimitReader(file, 64<<10))
var secrets map[string]string
if err := decoder.Decode(&secrets); err != nil {
-17
View File
@@ -6,7 +6,6 @@ import (
"mime"
"net/http"
"net/url"
"regexp"
"strconv"
"strings"
"time"
@@ -153,22 +152,6 @@ func attachmentVariant(query url.Values) (string, bool) {
}
}
var traceparentPattern = regexp.MustCompile(`^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$`)
func traceparent(value string) string {
if traceparentPattern.MatchString(value) {
return value
}
return ""
}
func tracestate(value string) string {
if len(value) <= 512 {
return value
}
return ""
}
func attachmentIDFromRequest(r *http.Request) (string, *apiError) {
parts := strings.Split(strings.Trim(r.URL.Path, "/"), "/")
attachmentID, valid := canonicalID(parts[3])
-15
View File
@@ -263,21 +263,6 @@ func scanAttachmentWithReferenceAndObjectKey(
return err
}
func scanAttachmentWithReference(row rowScanner, attachment *model.Attachment) error {
var stagingKey *string
err := row.Scan(
&attachment.ID, &attachment.ChatID, &attachment.OwnerID, &attachment.Filename,
&attachment.ContentType, &attachment.SizeBytes, &attachment.SHA256, &attachment.ObjectKey,
&attachment.Status, &attachment.CreatedAt, &attachment.UpdatedAt, &attachment.ReadyAt,
&attachment.PipelineVersion, &attachment.ErrorCode, &stagingKey,
&attachment.Referenced,
)
if stagingKey != nil {
attachment.StagingKey = *stagingKey
}
return err
}
func (s *Store) AttachmentReferenced(ctx context.Context, attachmentID string) (bool, error) {
const query = `SELECT EXISTS (SELECT 1 FROM message_attachments WHERE attachment_id = $1)`
var referenced bool
+3 -3
View File
@@ -40,7 +40,7 @@ func Run(ctx context.Context, config Config) error {
if err != nil {
return fmt.Errorf("listen: %w", err)
}
defer listener.Close()
defer func() { _ = listener.Close() }()
go func() {
<-ctx.Done()
_ = listener.Close()
@@ -66,7 +66,7 @@ func Run(ctx context.Context, config Config) error {
func serve(ctx context.Context, connection net.Conn, config Config, tlsConfiguration *tls.Config) {
client := tls.Server(connection, tlsConfiguration)
defer client.Close()
defer func() { _ = client.Close() }()
handshakeCtx, cancel := context.WithTimeout(ctx, config.DialTimeout)
defer cancel()
if err := client.HandshakeContext(handshakeCtx); err != nil {
@@ -76,7 +76,7 @@ func serve(ctx context.Context, connection net.Conn, config Config, tlsConfigura
if err != nil {
return
}
defer target.Close()
defer func() { _ = target.Close() }()
result := make(chan struct{}, 2)
copyConnection := func(destination, source net.Conn) {
+1 -1
View File
@@ -73,7 +73,7 @@ func handshake(serverConfig, clientConfig *tls.Config) (error, error) {
if err != nil {
return err, err
}
defer listener.Close()
defer func() { _ = listener.Close() }()
serverResult := make(chan error, 1)
go func() {
connection, acceptErr := listener.Accept()