mirror of
https://dev.azure.com/schwarzit/schwarzit.stackit-public/_git/audit-go
synced 2026-02-17 21:31:43 +00:00
Fix linter issues
This commit is contained in:
parent
a509aae2a6
commit
85f07ec14a
5 changed files with 12 additions and 19 deletions
|
|
@ -144,7 +144,7 @@ buf generate --include-imports
|
||||||
|
|
||||||
##### Build library
|
##### Build library
|
||||||
```bash
|
```bash
|
||||||
go mod download && go mod tidy && go get ./... && go fmt ./... && go vet ./... && go build ./... && go test ./...
|
go mod download && go mod tidy && go get ./... && go fmt ./... && go vet ./... && golangci-lint run && go build ./... && go test ./...
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Register buf validation schema in IntelliJ / Goland
|
#### Register buf validation schema in IntelliJ / Goland
|
||||||
|
|
|
||||||
|
|
@ -229,11 +229,9 @@ func (a *LegacyAuditApi) convertAndSerializeIntoLegacyFormat(
|
||||||
} else {
|
} else {
|
||||||
return nil, ErrUnsupportedObjectIdentifierType
|
return nil, ErrUnsupportedObjectIdentifierType
|
||||||
}
|
}
|
||||||
break
|
|
||||||
case *auditV1.RoutableAuditEvent_ObjectName:
|
case *auditV1.RoutableAuditEvent_ObjectName:
|
||||||
eventType = "SYSTEM_EVENT"
|
eventType = "SYSTEM_EVENT"
|
||||||
messageContext = nil
|
messageContext = nil
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
return nil, ErrUnsupportedResourceReferenceType
|
return nil, ErrUnsupportedResourceReferenceType
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -410,15 +410,12 @@ func validateProtobufMessagePayload(
|
||||||
if objectIdentifier.Type == auditV1.ObjectType_OBJECT_TYPE_ORGANIZATION {
|
if objectIdentifier.Type == auditV1.ObjectType_OBJECT_TYPE_ORGANIZATION {
|
||||||
assert.Equal(t, routingIdentifier.Identifier.String(), reference.ObjectIdentifier.Identifier)
|
assert.Equal(t, routingIdentifier.Identifier.String(), reference.ObjectIdentifier.Identifier)
|
||||||
}
|
}
|
||||||
break
|
|
||||||
case RoutingIdentifierTypeProject:
|
case RoutingIdentifierTypeProject:
|
||||||
assert.Equal(t, routingIdentifier.Identifier.String(), reference.ObjectIdentifier.Identifier)
|
assert.Equal(t, routingIdentifier.Identifier.String(), reference.ObjectIdentifier.Identifier)
|
||||||
assert.Equal(t, auditV1.ObjectType_OBJECT_TYPE_PROJECT, reference.ObjectIdentifier.Type)
|
assert.Equal(t, auditV1.ObjectType_OBJECT_TYPE_PROJECT, reference.ObjectIdentifier.Type)
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
assert.Fail(t, "Routing identifier type not expected")
|
assert.Fail(t, "Routing identifier type not expected")
|
||||||
}
|
}
|
||||||
break
|
|
||||||
case *auditV1.RoutableAuditEvent_ObjectName:
|
case *auditV1.RoutableAuditEvent_ObjectName:
|
||||||
assert.Nil(t, objectIdentifier)
|
assert.Nil(t, objectIdentifier)
|
||||||
assert.Nil(t, routingIdentifier)
|
assert.Nil(t, routingIdentifier)
|
||||||
|
|
@ -431,7 +428,6 @@ func validateProtobufMessagePayload(
|
||||||
switch data := routableAuditEvent.Data.(type) {
|
switch data := routableAuditEvent.Data.(type) {
|
||||||
case *auditV1.RoutableAuditEvent_UnencryptedData:
|
case *auditV1.RoutableAuditEvent_UnencryptedData:
|
||||||
assert.NoError(t, proto.Unmarshal(data.UnencryptedData.Data, &auditEvent))
|
assert.NoError(t, proto.Unmarshal(data.UnencryptedData.Data, &auditEvent))
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
assert.Fail(t, "Encrypted data not expected")
|
assert.Fail(t, "Encrypted data not expected")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ func (a *AmqpMessagingApi) Send(ctx context.Context, topic string, data []byte,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop the current sender, as it cannot connect to the broker anymore
|
// Drop the current sender, as it cannot connect to the broker anymore
|
||||||
slog.Error("message sender error, recreating", err)
|
slog.Error("message sender error, recreating", slog.Any("error", err))
|
||||||
|
|
||||||
err = a.resetConnection(ctx)
|
err = a.resetConnection(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -182,7 +182,7 @@ func (a *AmqpMessagingApi) resetConnection(ctx context.Context) error {
|
||||||
_ = (*a.session).Close(ctx)
|
_ = (*a.session).Close(ctx)
|
||||||
err := a.connection.Close()
|
err := a.connection.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("failed to close message connection", err)
|
slog.Error("failed to close message connection", slog.Any("error", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.connect()
|
return a.connect()
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,8 @@ func (c SolaceContainer) QueueCreate(ctx context.Context, queueName string) erro
|
||||||
_, err := c.sempClient.RequestWithBody(
|
_, err := c.sempClient.RequestWithBody(
|
||||||
ctx,
|
ctx,
|
||||||
"POST",
|
"POST",
|
||||||
fmt.Sprintf("/config/msgVpns/default/queues"), queueConfig)
|
"/config/msgVpns/default/queues",
|
||||||
|
queueConfig)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -220,7 +221,7 @@ func (c SolaceContainer) ValidateTopicName(topicSubscriptionTopicPattern string,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check topic name
|
// Check topic name
|
||||||
allowedTopicCharacters, err := regexp.Compile("[0-9A-Za-z-.]+(?:/[0-9A-Za-z-.]+)+|[0-9A-Za-z-.]+")
|
allowedTopicCharacters, err := regexp.Compile(`[0-9A-Za-z-.]+(?:/[0-9A-Za-z-.]+)+|[0-9A-Za-z-.]+`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -230,7 +231,7 @@ func (c SolaceContainer) ValidateTopicName(topicSubscriptionTopicPattern string,
|
||||||
|
|
||||||
// Check topic subscription topic pattern
|
// Check topic subscription topic pattern
|
||||||
allowedTopicSubscriptionCharacters, err := regexp.Compile(
|
allowedTopicSubscriptionCharacters, err := regexp.Compile(
|
||||||
"(?:(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\\*)(?:/(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\\*))+|(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\\*)|/>)|>")
|
`(?:(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\*)(?:/(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\*))+|(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\*)|/>)|>`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -257,27 +258,25 @@ func (c SolaceContainer) ValidateTopicName(topicSubscriptionTopicPattern string,
|
||||||
case '*':
|
case '*':
|
||||||
if name[i] == '/' {
|
if name[i] == '/' {
|
||||||
expectedNextCharacter = '/'
|
expectedNextCharacter = '/'
|
||||||
nextError = errors.New(fmt.Sprintf("Invalid character '/' at index %d", i))
|
nextError = fmt.Errorf("invalid character '/' at index %d", i)
|
||||||
subscriptionIndex++
|
subscriptionIndex++
|
||||||
}
|
}
|
||||||
break
|
|
||||||
case '/':
|
case '/':
|
||||||
if name[i] != '/' {
|
if name[i] != '/' {
|
||||||
return errors.New(fmt.Sprintf("Expected character '/', got %c at index %d", name[i], i))
|
return fmt.Errorf("expected character '/', got %c at index %d", name[i], i)
|
||||||
}
|
}
|
||||||
subscriptionIndex++
|
subscriptionIndex++
|
||||||
break
|
|
||||||
case '>':
|
case '>':
|
||||||
// everything is allowed
|
// everything is allowed
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
if name[i] != topicSubscriptionTopicPattern[subscriptionIndex] {
|
if name[i] != topicSubscriptionTopicPattern[subscriptionIndex] {
|
||||||
return errors.New(fmt.Sprintf(
|
return fmt.Errorf(
|
||||||
"Expected character %c, got %c at index %d",
|
"expected character %c, got %c at index %d",
|
||||||
topicSubscriptionTopicPattern[subscriptionIndex],
|
topicSubscriptionTopicPattern[subscriptionIndex],
|
||||||
name[i],
|
name[i],
|
||||||
i,
|
i,
|
||||||
))
|
)
|
||||||
} else {
|
} else {
|
||||||
subscriptionIndex++
|
subscriptionIndex++
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue