Skip to content

Commit

Permalink
return data as is on incorrect AcraStruct begin tag (#305)
Browse files Browse the repository at this point in the history
* return data as is on incorrect AcraStruct begin tag

* gofmt
  • Loading branch information
Lagovas authored and vixentael committed Jan 24, 2019
1 parent 2986f54 commit ee0c983
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion decryptor/mysql/decryptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,16 @@ func (decryptor *MySQLDecryptor) decryptWholeBlock(block []byte) ([]byte, error)
if !decryptor.IsWithZone() || decryptor.IsMatchedZone() {
skippedBegin, err := decryptor.SkipBeginInBlock(block)
if err != nil {
return nil, err
return block, nil
}
newData, err := decryptor.decryptBlock(bytes.NewReader(skippedBegin), decryptor.GetMatchedZoneID(), decryptor.GetPrivateKey)
if err != nil {
base.AcrastructDecryptionCounter.WithLabelValues(base.DecryptionTypeFail).Inc()
if err := decryptor.checkPoisonRecord(block); err != nil {
return nil, err
}
decryptor.log.Debugln("Can't decrypt block")
return block, nil
}
base.AcrastructDecryptionCounter.WithLabelValues(base.DecryptionTypeSuccess).Inc()
if decryptor.IsWithZone() && err == nil && len(newData) != len(block) {
Expand Down
4 changes: 2 additions & 2 deletions decryptor/mysql/response_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (handler *MysqlHandler) ClientToDbConnector(errCh chan<- error) {
prometheusLabels := []string{base.DecryptionDBMysql}
// use pointers to function where should be stored some function that should be called if code return error and interrupt loop
// default value empty func to avoid != nil check
var timerObserveFunc = func() {}
var timerObserveFunc = func() time.Duration { return 0 }
var packetSpanEndFunc = func() {}
var censorSpanEndFunc = func() {}
defer func() {
Expand Down Expand Up @@ -655,7 +655,7 @@ func (handler *MysqlHandler) DbToClientConnector(errCh chan<- error) {
// use pointers to function where should be stored some function that should be called if code return error and interrupt loop
// default value empty func to avoid != nil check
var packetSpanEndFunc = func() {}
var timerObserveFunc = func() {}
var timerObserveFunc = func() time.Duration { return 0 }
defer func() {
timerObserveFunc()
packetSpanEndFunc()
Expand Down
2 changes: 1 addition & 1 deletion decryptor/postgresql/pg_decryptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (proxy *PgProxy) PgProxyClientRequests(acraCensor acracensor.AcraCensorInte
// use pointers to function where should be stored some function that should be called if code return error and interrupt loop
// default value empty func to avoid != nil check
var spanEndFunc = func() {}
var timerObserveFunc = func() {}
var timerObserveFunc = func() time.Duration { return 0 }
// always call span.End for case if was error
defer func() {
spanEndFunc()
Expand Down

0 comments on commit ee0c983

Please sign in to comment.