Files
Open_Ultra_SAST/benchmarks/pairs/agent-vfc/lensops-kubernetesmanagement-fe4910/fixed.tsx
T
Marius CiepluchandClaude Opus 5 309faad266 measure: the candidate generator must be the IR, not the ruleset
A candidate-driven detector can only judge sites something else enumerates,
so the enumerator caps recall. Measured over the 58 scorable web pairs before
building anything:

  pattern ruleset:  12.1% ceiling -- and the misses are not near-misses, the
                    ruleset finds nothing at all in most of these files
  semantic IR:      96.6% ceiling, a median of ten call sites and bindings
                    inside the labeled function

The ruleset would have capped us at 12.1% against the 64.9% the unconstrained
loop already reaches. That design was one commit from being built.

Two corpus defects found on the way, both mine from task 4.1. The overleaf
excerpt started mid-import, because `_declarator_start` walks back to the
nearest `}` and Overleaf writes JavaScript without semicolons, so the nearest
one was inside `import { expressify }`. It then ended mid-object-literal,
because registration mentions were appended as bare lines. Neither parsed,
and a pair that cannot be parsed cannot be scored. Registration mentions now
expand to the statement that contains them; the ceiling moved 94.8% -> 96.6%.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01T7XD7x5KonMdmGRkp63EQG
2026-09-06 16:04:07 +02:00

91 lines
3.4 KiB
TypeScript

// Provenance: amitknigam84/lensops loadNamespaces (fixed).
// repo: amitknigam84/lensops
// commit: fe49109aedfe21dea4d24d4d9f2fa3f1ecfb6c84
// parent: 9b87ecc3a44a7fe2a5185cca1fe52441647d5748
// commit_url: https://github.com/amitknigam84/lensops/commit/fe49109aedfe21dea4d24d4d9f2fa3f1ecfb6c84
// cve:
// license: MIT
// function: loadNamespaces
// relpath: components/KubernetesManagement.tsx
// provenance: agent
// mechanism: missing_auth_guard
// upstream_start: 805
const loadNamespaces = async (skipConnectionCheck = false) => {
if (!skipConnectionCheck && !isConnected) {
setErrorMessage('Please connect to a Kubernetes cluster first')
return
}
setIsLoading(true)
setErrorMessage(null)
try {
console.log('📋 Loading namespaces from:', `${apiUrl}/k8s/namespaces`)
const response = await fetch(`${apiUrl}/k8s/namespaces`, {
headers: token ? { 'Authorization': `Bearer ${token}` } : {},
})
if (!response.ok) {
const errorData = await response.json().catch(() => ({ message: 'Unknown error' }))
throw new Error(errorData.message || `HTTP ${response.status}: ${response.statusText}`)
}
const data = await response.json()
console.log('📋 Namespaces response:', data)
if (data.success && data.namespaces) {
setNamespaces(data.namespaces)
setIsConnected(true) // ✅ Mark as connected after successfully loading namespaces
// Always use deployed namespace (from ServiceAccount)
const namespaceToUse = data.podNamespace || (data.namespaces.length > 0 ? data.namespaces[0].name : null);
if (namespaceToUse) {
setDeployedNamespace(namespaceToUse)
setSelectedNamespace(namespaceToUse)
console.log('📌 Using deployed namespace:', namespaceToUse)
// Automatically load resources for the deployed namespace
console.log('📦 Loading resources from deployed namespace:', namespaceToUse)
setTimeout(() => {
loadData()
}, 100)
} else {
setErrorMessage('⚠️ No namespace found. Please check POD_NAMESPACE configuration.')
}
} else {
setErrorMessage(data.message || data.error || 'Failed to load namespaces')
}
} catch (error: any) {
console.error('❌ Failed to load namespaces:', error)
setErrorMessage(error.message || 'Failed to load namespaces. Please check your connection and try again.')
} finally {
setIsLoading(false)
}
}
try {
await loadNamespaces(true)
await loadData()
} catch (err) {
console.error('Error loading namespaces:', err)
}
try {
await loadNamespaces(true)
// Always load data after namespaces are loaded (defaults to 'all' to show all resources)
await loadData()
} catch (err) {
console.error('Error loading namespaces after connection:', err)
setErrorMessage('✅ Connected, but failed to load namespaces. Click "Load Namespaces" to retry.')
}
if (apiUrl && !deployedNamespace) {
loadNamespaces(true)
}
if (apiUrl && !isConnected && !isConnecting) {
console.log('🚀 Auto-connecting to Kubernetes cluster via ServiceAccount...')
loadNamespaces(true) // Skip connection check since we're auto-connecting
}
if (apiUrl && !isConnected) {
loadNamespaces(true);
}