Skip to content

Commit 250971b

Browse files
chore: cleanup
1 parent 7f9482a commit 250971b

8 files changed

Lines changed: 1 addition & 53 deletions

File tree

backend/ai/app/services/summarization.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ def __init__(self) -> None:
2424
self.api_key = os.getenv("OPENAI_API_KEY", "")
2525
self.base_url = os.getenv("OPENAI_BASE_URL", "https://openrouter.ai/api/v1")
2626

27-
# Primary model from env, plus fallback
2827
primary_model = os.getenv("OPENAI_MODEL", "z-ai/glm-4.5-air:free")
2928
self.models = [primary_model]
3029

31-
# Add fallback/alternative models for rotation
32-
# Including openai and google free models as requested
3330
alternatives = [
3431
"meta-llama/llama-3.1-405b-instruct:free",
3532
"openai/gpt-oss-120b:free",
@@ -58,7 +55,6 @@ def _call_llm(
5855
raise ValueError("LLM client not initialized")
5956

6057
for attempt in range(max_retries):
61-
# Rotate models: try primary, then secondary, etc.
6258
model = self.models[attempt % len(self.models)]
6359

6460
try:
@@ -139,9 +135,7 @@ def summarize_issues(
139135
)
140136

141137
content = response.choices[0].message.content or "{}"
142-
# Try to parse JSON from response
143138
try:
144-
# Handle markdown code blocks
145139
if "```json" in content:
146140
content = content.split("```json")[1].split("```")[0]
147141
elif "```" in content:
@@ -209,15 +203,13 @@ def generate_commands(
209203

210204
content = response.choices[0].message.content or "{}"
211205
try:
212-
# Handle markdown code blocks
213206
if "```json" in content:
214207
content = content.split("```json")[1].split("```")[0]
215208
elif "```" in content:
216209
content = content.split("```")[1].split("```")[0]
217210

218211
result = json.loads(content.strip())
219212
commands = result.get("commands", [])
220-
# Ensure all commands are strings
221213
return [str(cmd) for cmd in commands if cmd]
222214
except json.JSONDecodeError:
223215
logger.warning(f"Failed to parse commands JSON: {content}")
@@ -277,10 +269,8 @@ def SummarizeFindings(
277269

278270
logger.info(f"Summarizing {len(findings)} findings for account {account_id}")
279271

280-
# Group findings by check_id and service
281272
grouped = self._group_findings(findings)
282273

283-
# Create finding groups with LLM summaries
284274
finding_groups = []
285275
action_items = []
286276

@@ -313,7 +303,6 @@ def SummarizeFindings(
313303

314304
logger.info("Finished processing all groups.")
315305

316-
# Calculate risk summary
317306
risk_summary = self._calculate_risk_summary(findings)
318307

319308
return summarization_pb2.SummarizeFindingsResponse(
@@ -388,37 +377,29 @@ def _create_finding_group(
388377
service, check_id = group_key.split(":", 1)
389378
region = first.region or "us-east-1"
390379

391-
# Count failed findings
392380
failed_findings = [
393381
f for f in findings if f.status == summarization_pb2.FINDING_STATUS_FAIL
394382
]
395383
failed_count = len(failed_findings)
396384

397-
# Determine highest severity
398385
severities = [f.severity for f in findings]
399386
max_severity = max(severities) if severities else 0
400387

401-
# Collect resource IDs
402388
resource_ids = [f.resource_id for f in findings]
403389

404-
# Generate title
405390
if failed_count > 0:
406391
title = f"{failed_count} {service.upper()} resources failed {check_id}"
407392
else:
408393
title = f"All {len(findings)} {service.upper()} resources passed {check_id}"
409394

410-
# Calculate risk score
411395
risk_score = self._calculate_group_risk_score(findings, max_severity)
412396

413-
# Determine recommended action
414397
action = self._determine_action(max_severity, failed_count)
415398

416-
# Collect compliance frameworks
417399
compliance = set()
418400
for f in findings:
419401
compliance.update(f.compliance)
420402

421-
# Generate LLM summary and remedy for failed findings
422403
summary = ""
423404
remedy = ""
424405
if failed_count > 0:
@@ -492,7 +473,6 @@ def _create_action_item(
492473
"""Create an action item with LLM-generated CLI commands."""
493474
region = failed_findings[0].region if failed_findings else "us-east-1"
494475

495-
# Generate remediation commands using LLM
496476
commands = self.llm.generate_commands(
497477
service=group.service,
498478
region=region,

backend/api/graph/schema.resolvers.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/api/internal/awsauth/credentials.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ func (c *CredentialCache) refreshExpiring() {
140140
for _, cred := range expiring {
141141
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
142142
if _, err := c.RefreshCredentials(ctx, cred.accountID, cred.externalID); err != nil {
143-
// TODO: Add proper logging when logger is available
144-
// For now, silently continue to avoid crashes
145143
_ = err
146144
}
147145
cancel()

backend/api/internal/middleware/auth/auth.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,7 @@ func Middleware() gin.HandlerFunc {
5757
}
5858

5959
clientKey := os.Getenv("CLERK_SECRET_KEY")
60-
// if clientKey == "" {
61-
// We don't want to panic here in case of misconfiguration in dev, just warn
62-
// log.Println("WARNING: CLERK_SECRET_KEY is missing")
63-
// }
6460

65-
// If no client available (no key), or no header, just finish
66-
// Ideally we should block if key is present but header missing
6761
if clientKey == "" {
6862
c.Next()
6963
return
@@ -78,7 +72,6 @@ func Middleware() gin.HandlerFunc {
7872

7973
header := r.Header.Get("Authorization")
8074
if header == "" {
81-
// Unauthenticated
8275
c.Next()
8376
return
8477
}
@@ -128,7 +121,6 @@ func EmailFromContext(ctx context.Context) (string, error) {
128121
if user == nil {
129122
return "", fmt.Errorf("not logged in")
130123
}
131-
// Simplified email retrieval
132124
if len(user.EmailAddresses) > 0 {
133125
return user.EmailAddresses[0].EmailAddress, nil
134126
}

backend/api/internal/scanner/coordinator.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ type ScanTaskResult struct {
5252
func (c *Coordinator) StartScan(ctx context.Context, config ScanConfig) (*ScanResult, error) {
5353
startedAt := time.Now().UTC()
5454

55-
// Build list of scan tasks
5655
var tasks []ScanTask
5756
for _, region := range config.Regions {
5857
for _, service := range config.Services {
@@ -68,10 +67,8 @@ func (c *Coordinator) StartScan(ctx context.Context, config ScanConfig) (*ScanRe
6867
return nil, fmt.Errorf("no valid scan tasks: check that services have registered scanners")
6968
}
7069

71-
// Execute tasks in parallel
7270
results := c.executeParallel(ctx, tasks)
7371

74-
// Aggregate results
7572
var allFindings []Finding
7673
var scanErrors []error
7774

@@ -83,7 +80,6 @@ func (c *Coordinator) StartScan(ctx context.Context, config ScanConfig) (*ScanRe
8380
allFindings = append(allFindings, result.Findings...)
8481
}
8582

86-
// Count passed and failed checks
8783
passedChecks := 0
8884
failedChecks := 0
8985
for _, f := range allFindings {
@@ -120,14 +116,12 @@ func (c *Coordinator) executeParallel(ctx context.Context, tasks []ScanTask) []S
120116
resultsChan := make(chan ScanTaskResult, len(tasks))
121117
tasksChan := make(chan ScanTask, len(tasks))
122118

123-
// Start worker pool
124119
for i := 0; i < maxWorkers; i++ {
125120
wg.Add(1)
126121
go func() {
127122
defer wg.Done()
128123

129124
for task := range tasksChan {
130-
// Check for context cancellation before processing
131125
select {
132126
case <-ctx.Done():
133127
resultsChan <- ScanTaskResult{
@@ -140,21 +134,18 @@ func (c *Coordinator) executeParallel(ctx context.Context, tasks []ScanTask) []S
140134

141135
result := ScanTaskResult{Task: task}
142136

143-
// Create scanner for this service/region
144137
factory, exists := c.scanners[task.Service]
145138
if !exists {
146139
result.Error = fmt.Errorf("no scanner registered for service %s", task.Service)
147140
resultsChan <- result
148141
continue
149142
}
150143

151-
// Create regional config
152144
regionalCfg := c.cfg.Copy()
153145
regionalCfg.Region = task.Region
154146

155147
scanner := factory(regionalCfg, task.Region, c.accountID)
156148

157-
// Execute scan with context
158149
findings, err := scanner.Scan(ctx, task.Region)
159150
if err != nil {
160151
result.Error = err
@@ -168,21 +159,18 @@ func (c *Coordinator) executeParallel(ctx context.Context, tasks []ScanTask) []S
168159
}()
169160
}
170161

171-
// Send tasks to workers
172162
go func() {
173163
for _, task := range tasks {
174164
tasksChan <- task
175165
}
176166
close(tasksChan)
177167
}()
178168

179-
// Wait for all workers to complete
180169
go func() {
181170
wg.Wait()
182171
close(resultsChan)
183172
}()
184173

185-
// Collect results
186174
var results []ScanTaskResult
187175
for result := range resultsChan {
188176
results = append(results, result)

frontend/app/(dashboard)/accounts/_components/add-account-dialog.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@ export function AddAccountDialog() {
3434

3535
const handleVerify = async () => {
3636
setIsVerifying(true);
37-
// TODO: Call GraphQL mutation to verify account
3837
setTimeout(() => {
3938
setIsVerifying(false);
4039
setIsVerified(true);
4140
}, 2000);
4241
};
4342

4443
const handleConnect = async () => {
45-
// TODO: Call GraphQL mutation to connect account
4644
setOpen(false);
4745
// Reset state
4846
setStep(1);

frontend/app/(dashboard)/scans/_components/new-scan-form.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export function NewScanForm() {
6666

6767
const handleStartScan = async () => {
6868
setIsScanning(true);
69-
// TODO: Call GraphQL mutation to start scan
7069
console.log("Starting scan with:", {
7170
account: selectedAccount,
7271
services: selectedServices,

frontend/components/ui/sidebar.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ function SidebarProvider({
6868
const isMobile = useIsMobile();
6969
const [openMobile, setOpenMobile] = React.useState(false);
7070

71-
// This is the internal state of the sidebar.
72-
// We use openProp and setOpenProp for control from outside the component.
7371
const [_open, _setOpen] = React.useState(defaultOpen);
7472
const open = openProp ?? _open;
7573
const setOpen = React.useCallback(
@@ -81,18 +79,15 @@ function SidebarProvider({
8179
_setOpen(openState);
8280
}
8381

84-
// This sets the cookie to keep the sidebar state.
8582
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
8683
},
8784
[setOpenProp, open],
8885
);
8986

90-
// Helper to toggle the sidebar.
9187
const toggleSidebar = React.useCallback(() => {
9288
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
9389
}, [isMobile, setOpen, setOpenMobile]);
9490

95-
// Adds a keyboard shortcut to toggle the sidebar.
9691
React.useEffect(() => {
9792
const handleKeyDown = (event: KeyboardEvent) => {
9893
if (
@@ -108,8 +103,6 @@ function SidebarProvider({
108103
return () => window.removeEventListener("keydown", handleKeyDown);
109104
}, [toggleSidebar]);
110105

111-
// We add a state so that we can do data-state="expanded" or "collapsed".
112-
// This makes it easier to style the sidebar with Tailwind classes.
113106
const state = open ? "expanded" : "collapsed";
114107

115108
const contextValue = React.useMemo<SidebarContextProps>(

0 commit comments

Comments
 (0)