Skip to content

Commit

Permalink
Input validation and parent process checking on logger back-end.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Jul 27, 2024
1 parent 28ce63c commit 82aed10
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backend/logger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
"encoding/json"
"fmt"
"os"

"github.com/nthnn/QLBase/logger/proc"
)

func dumpLogs() {
Expand Down Expand Up @@ -63,6 +65,10 @@ func dumpLogs() {
}

func main() {
if !proc.IsParentProcessPHP() {
os.Exit(0)
}

if len(os.Args) == 3 {
dumpLogs()
os.Exit(0)
Expand All @@ -80,6 +86,12 @@ func main() {
userAgent := args[4]
sender := args[5]

if !validateApiKey(apiKey) ||
!validateTimestamp(dateTime) ||
!validateSender(sender) {
os.Exit(0)
}

DispatchWithCallback(func(db *sql.DB) {
query, _ := db.Query("INSERT INTO " + apiKey +
"_logs (origin, action, datetime, user_agent, sender) VALUES(\"" +
Expand Down

0 comments on commit 82aed10

Please sign in to comment.