Conversation
chore: remove unnecessary pointers in strings
|
No actionable comments were generated in the recent review. 🎉 WalkthroughWhitespace/indentation tweaks in a CLI command file and conversion of six SignInActivity struct fields from pointer types ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@models/azure/user-signinactivity.go`:
- Around line 4-11: The SignInActivity struct fields were changed from *string
to string, breaking code that dereferences pointers (e.g., user_test.go expects
u.SignInActivity.LastSuccessfulSignInDateTime to be a *string) and changing
null-vs-empty semantics; revert the fields in SignInActivity
(LastSignInDateTime, LastSignInRequestId, LastNonInteractiveSignInDateTime,
LastNonInteractiveSignInRequestId, LastSuccessfulSignInDateTime,
LastSuccessfulSignInRequestId) back to *string so tests and JSON null handling
work as before and update any callers only if you intentionally want to change
semantics.
| type SignInActivity struct { | ||
| LastSignInDateTime *string `json:"lastSignInDateTime,omitempty"` | ||
| LastSignInRequestId *string `json:"lastSignInRequestId,omitempty"` | ||
| LastNonInteractiveSignInDateTime *string `json:"lastNonInteractiveSignInDateTime,omitempty"` | ||
| LastNonInteractiveSignInRequestId *string `json:"lastNonInteractiveSignInRequestId,omitempty"` | ||
| LastSuccessfulSignInDateTime *string `json:"lastSuccessfulSignInDateTime,omitempty"` | ||
| LastSuccessfulSignInRequestId *string `json:"lastSuccessfulSignInRequestId,omitempty"` | ||
| LastSignInDateTime string `json:"lastSignInDateTime,omitempty"` | ||
| LastSignInRequestId string `json:"lastSignInRequestId,omitempty"` | ||
| LastNonInteractiveSignInDateTime string `json:"lastNonInteractiveSignInDateTime,omitempty"` | ||
| LastNonInteractiveSignInRequestId string `json:"lastNonInteractiveSignInRequestId,omitempty"` | ||
| LastSuccessfulSignInDateTime string `json:"lastSuccessfulSignInDateTime,omitempty"` | ||
| LastSuccessfulSignInRequestId string `json:"lastSuccessfulSignInRequestId,omitempty"` | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for SignInActivity usages and potential nil checks
echo "=== Finding all SignInActivity usages in Go files ==="
rg -n 'SignInActivity' --type go -B 2 -A 5
echo ""
echo "=== Searching for potential nil checks on these fields ==="
rg -n '(LastSignInDateTime|LastSignInRequestId|LastNonInteractiveSignInDateTime|LastNonInteractiveSignInRequestId|LastSuccessfulSignInDateTime|LastSuccessfulSignInRequestId)\s*(!= nil|== nil|\*\.|\&)' --type go -B 2 -A 2
echo ""
echo "=== Looking for SignInActivity struct definition and file context ==="
fd 'user-signinactivity.go' --type f | xargs cat -n
echo ""
echo "=== Checking for json.Unmarshal patterns with SignInActivity ==="
rg -n 'Unmarshal.*SignInActivity\|SignInActivity.*Unmarshal' --type go -B 3 -A 3Repository: SpecterOps/AzureHound
Length of output: 4062
🏁 Script executed:
# Read the test file to confirm the pointer dereference issue
cat -n models/azure/user_test.go | sed -n '23,50p'Repository: SpecterOps/AzureHound
Length of output: 1127
Test file will not compile: pointer dereferences incompatible with string fields.
The change from *string to string fields breaks test code at models/azure/user_test.go:44-45, which attempts to dereference LastSuccessfulSignInDateTime:
if *u.SignInActivity.LastSuccessfulSignInDateTime != "2025-01-27T22:20:22Z" {This will fail to compile because string values cannot be dereferenced. Additionally, the semantic change remains: null values from the API (as shown in the test's JSON payload on lines 32-33) will now unmarshal to empty strings instead of nil, affecting how missing sign-in activity is distinguished from explicitly empty values.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@models/azure/user-signinactivity.go` around lines 4 - 11, The SignInActivity
struct fields were changed from *string to string, breaking code that
dereferences pointers (e.g., user_test.go expects
u.SignInActivity.LastSuccessfulSignInDateTime to be a *string) and changing
null-vs-empty semantics; revert the fields in SignInActivity
(LastSignInDateTime, LastSignInRequestId, LastNonInteractiveSignInDateTime,
LastNonInteractiveSignInRequestId, LastSuccessfulSignInDateTime,
LastSuccessfulSignInRequestId) back to *string so tests and JSON null handling
work as before and update any callers only if you intentionally want to change
semantics.
Fix a formatting issue
Remove unnecessary string pointers
Summary by CodeRabbit
Style
Refactor
Tests