@code-sentinel-cli/code-sentinel-cli 4.0.4 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +1198 -1157
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1199 -1158
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -6,7 +6,7 @@ import { randomBytes, createCipheriv, createDecipheriv, createHash, randomUUID,
|
|
|
6
6
|
import * as sp2 from 'path';
|
|
7
7
|
import { resolve, join, dirname, relative, basename, sep, isAbsolute, extname, posix, normalize } from 'path';
|
|
8
8
|
import * as nativeFs from 'fs';
|
|
9
|
-
import { existsSync, readFileSync,
|
|
9
|
+
import { existsSync, readFileSync, constants, statSync, stat as stat$1, realpathSync, realpath, readdirSync, readdir as readdir$1, unwatchFile, watchFile, watch as watch$1, writeFileSync, openSync, fstatSync, closeSync, readSync, mkdirSync } from 'fs';
|
|
10
10
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
11
11
|
import { Language, Parser, Query } from 'web-tree-sitter';
|
|
12
12
|
import { Project, SyntaxKind, Node, VariableDeclarationKind, ScriptKind } from 'ts-morph';
|
|
@@ -20,11 +20,11 @@ import { generateText } from 'ai';
|
|
|
20
20
|
import { type, tmpdir, homedir, totalmem } from 'os';
|
|
21
21
|
import { cosmiconfig } from 'cosmiconfig';
|
|
22
22
|
import { stringify, parse as parse$1 } from 'yaml';
|
|
23
|
+
import { execFile as execFile$1, spawn, execFileSync, execSync } from 'child_process';
|
|
24
|
+
import { promisify } from 'util';
|
|
23
25
|
import { createClient } from '@libsql/client';
|
|
24
26
|
import 'mariadb';
|
|
25
27
|
import { Command, Option } from 'commander';
|
|
26
|
-
import { execFile as execFile$1, spawn, execFileSync, execSync } from 'child_process';
|
|
27
|
-
import { promisify } from 'util';
|
|
28
28
|
import { password, confirm, input, select } from '@inquirer/prompts';
|
|
29
29
|
import { render, Static, Box, Text } from 'ink';
|
|
30
30
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
@@ -11603,7 +11603,7 @@ function parseParams2(url) {
|
|
|
11603
11603
|
function normalizeUrl(url) {
|
|
11604
11604
|
return url.replace(/^\/+/, "");
|
|
11605
11605
|
}
|
|
11606
|
-
var createCompositeParser, SUPPORTED, createTextParser, requireFromHere, grammarCache, parserInitialized, initParser, resolveGrammarPath, loadGrammar, LANGUAGE_TO_GRAMMAR, SUPPORTED2, createTreeSitterParser, asTreeSitterTree, SUPPORTED3, scriptKindFor, createTsMorphParser, createParser, TS_LANGUAGES, EXTENSIONS, TS_SOURCE_EXTENSIONS_BY_RUNTIME_EXT, scriptKindFor2, normalizeRelativePath, candidatePaths, normalizeConfigPath, stripJsonComments, loadTsConfigResolver, matchPathPattern, applyPathTarget, resolveAliasModule, resolveModule, aliasIfDifferent, exportedSymbols, expressionRootName, addSymbol, compareText, variableBindingNames, importEqualsSpecifier, extractSymbols, fingerprintFor, createTsAstDependencyGraphBuilder, isTsLike, debug, warn, tryLoad, trySave, createIncrementalAstGraphBuilder, SOURCES, SINKS, SANITIZERS, DEFAULT_TS_TAINT_TABLES, JAVA_SOURCES, JAVA_SINKS, JAVA_SANITIZERS, DEFAULT_JAVA_TAINT_TABLES, EMPTY_SUMMARY, paramSentinel, PARAM_SENTINEL_RE, MAX_CROSS_FILE_DEPTH, TYPE_DECL_NODES, indexCache, SCOPE_BOUNDARY, SCOPE_BOUNDARY2, TYPE_DECL, STRING_PASSTHROUGH, ARG_PASSTHROUGH, CONTAINER_ELEMENT, BUILDER_APPENDERS, COLLECTION_MUTATORS, RECEIVER_FOLD_MUTATORS, CONDITIONAL_CONSTRUCT, EMPTY_SUMMARY2, paramSentinel2, PARAM_SENTINEL_RE2, MAX_CROSS_METHOD_DEPTH, SANITIZE_CALL, BYPASS_CALL, PREFIX_GATE, MAX_VALUE_HOPS, SOURCE_PATTERNS, maskJavaComments, maskedCorpusCache, maskJavaFiles, MAPPING_ANNOTATIONS, PARAM_ANNOTATIONS, AUTHZ_ANNOTATIONS, VALIDATION_ANNOTATIONS, annotationScanner, TYPE_DECL2, MODIFIER, METHOD_NAME, LEADING_ANNOTATION, simpleName, lineOf, readBalanced, annotationArgs, firstStringLiteral, readMappingPath, readMappingMethod, joinPaths, skipToDeclaration, isTypeDeclaration, splitParams, parseParam, readAuthAnnotations, ROLE_ANNOTATIONS, stripRolePrefix, readAuthRoles, precedingBlock, readClassContext, extractFromFile, extractHttpEndpoints, findEnclosingEndpoint, SINK_ATTACKS, AI_TRIAGE_ATTACK_ALIASES, SOURCE_KIND, kindsFromSources, deriveAuthContext, resolveCompanionParams, resolveInjectionPoint, buildServerRequest, buildClientRequest, generateAttackScenario, UNASSESSED_CATALOG, BY_ID, buildUnassessedItems, INJECTION_LANGUAGES, TIER_A_INJECTION_ITEMS, CONFIRMED_LIMITATION, INCONCLUSIVE_LIMITATION, evidenceFrom, byFileLine, CHECKLIST_VERDICT_RANK, mergeEqualRank, dedupeByChecklistId, scenarioByFileLine, PENTEST_CHECKLIST_TOTAL, DECLARED_CHECKLIST_IDS, buildChecklistCoverage, buildCoverage, assembleAssessment, MAX_EVIDENCE3, REVIEW_SIGNAL_MAP, asJsonRecord, readReviewFinding, parseReviewReport, evidenceOf, sortEvidence, foldReviewSignals, MAX_EVIDENCE22, AUTHORIZATION_RISK_EVIDENCE, MASS_ASSIGNMENT_EVIDENCE, OWNERSHIP_SCOPE_EVIDENCE, STATE_TRANSITION_EVIDENCE, AI_SIGNAL_MAP, readPerRule, parseAiReviewReport, evidenceOf2, sortEvidence2, scopeClauseOf, provenanceOf, skipReasonOf, anchorResolves, anchorOf, unresolvableCitationClause, citationGateClause, citationTargetNoun, anchorAccepts, foldAiSignals, IMPORT_LINE_RE, isImportOrPackageLine, CSRF_SPEC, CORS_SPEC, HEADERS_SPEC, STACKTRACE_SPEC, MESSAGE_SPEC, COOKIE_SPEC, SESSION_FIXATION_SPEC, SESSION_TIMEOUT_SPEC, AUTH_CACHE_SPEC, lineOf2, SECURITY_CONFIG_RE, CSRF_DISABLE_RE, CORS_WILDCARD_RE, CROSS_ORIGIN_BARE_RE, ALLOW_CREDENTIALS_RE, CORS_EXPLICIT_ORIGIN_RE, CORS_ANY_RE, HEADERS_DISABLE_RES, HEADERS_CONFIGURED_RE, CSP_CONFIGURED_RE, STACKTRACE_EXPOSE_RE, STACKTRACE_NEVER_RE, MESSAGE_EXPOSE_RE, MESSAGE_NEVER_RE, COOKIE_CONTEXT_RE, COOKIE_INSECURE_CHECKS, COOKIE_HARDENED_RE, SESSION_FIXATION_DISABLED_RE, CACHE_CONTROL_DISABLE_RE, CACHE_CONTROL_CONFIGURED_RE, SESSION_TIMEOUT_PATH_RE, SESSION_BLOCK_HEADER_RE, SESSION_TIMEOUT_LEAF_RE, YAML_INDENT_RE, control, configEvidence, firstMatch, firstMatchAny, scanCsrf, CORS_ORIGINS_YAML_RE, CORS_CREDENTIALS_YAML_RE, isWildcardOrigins, corsConfigRank, corsOriginHits, scanCors, scanSecurityHeaders, NON_PROD_PROFILE_RE, scanStacktraceExposure, scanErrorMessageExposure, scanCookieAttributes, scanSessionFixation, scanAuthCacheControl, findSessionTimeout, timeoutNeverExpires, timeoutToMinutes, JWT_VALIDITY_RE, NON_PROD_CONFIG_RE, findJwtValidities, hoursOf, judgeJwtValidity, judgeServletTimeout, scanSessionTimeout, scanSecurityConfig, TEST_SOURCE_SET_RE, isTestSourcePath, WEAK_CRYPTO_SPEC, MAX_EVIDENCE32, lineOf3, classifyAlgorithm, GET_INSTANCE_RE, COMMONS_DIGEST_RE, GUAVA_HASHING_RE, SECRET_KEY_SPEC_RE, SHORTHAND_ALGO, collectWeakHits, STRONG_CRYPTO_RE, STRONG_CRYPTO_RE_G, firstStrong, evidence, item, scanWeakCrypto, REGEX_PRECEDING_KEYWORDS, isIdentChar, regexAllowedAt, maskJsComments, maskedCorpusCache2, maskJsFiles, BROWSER_STORAGE_SPEC, MAX_EVIDENCE4, lineOf4, HIGH_SENSITIVITY_RE, TOKEN_FAMILY_RE, classifyStorageKey, VALUE_TOKEN_FAMILY_RE, classifyStorageValue, keyToken, SET_ITEM_RE, BRACKET_ASSIGN_RE, STORAGE_USE_RE, IDB_CONTEXT_RE, LOCALFORAGE_SET_RE, IDB_STORE_WRITE_RE, collectStorageHits, collectIndexedDbHits, finalizeHits, firstStorageUse, evidence2, item2, scanSensitiveBrowserStorage, AT_REST_SPEC, MAX_EVIDENCE5, lineOf5, PWD_GETTER, PWD_EQUALS_RECEIVER_RE, PWD_EQUALS_ARG_RE, collectPasswordComparisonHits, SENSITIVE_FIELD_NAMES, FIELD_DECL_RE, FIELD_PROTECTED_RE, precedingBlock2, collectPlaintextFieldHits, finalizeHits2, PROTECTION_RE, firstProtection, AT_REST_SURFACE_RE, evidence3, item3, scanSensitiveDataAtRest, PADDING_ORACLE_SPEC, MAX_EVIDENCE6, lineOf6, GET_INSTANCE_RE2, collectCbcHits, BAD_PADDING_CATCH_RE, collectBadPaddingHits, finalizeHits3, AEAD_RE, firstAead, CIPHER_SURFACE_RE, evidence4, item4, scanPaddingOracle, LOGGING_SPEC, MAX_EVIDENCE7, lineOf7, JAVA_LOG_CALL_RE, JAVA_CONSOLE_CALL_RE, JS_CONSOLE_CALL_RE, LOG_SURFACE_RE, stripStringLiterals, SECRET_RE, PII_RE, PROTECTED_TAIL_RE, findSensitiveToken, collectSensitiveContainers, findSensitiveArgument, findSensitiveOutput, firstLogSurface, evidence5, item5, scanSensitiveLogging, CHECKLIST_ID, CONTROL_ID, TITLE, CWE, MAX_EVIDENCE8, ADMIN_PATH_RE, ADMIN_CONTROLLER_RE, isAdminEndpoint, ADMIN_ROLE_RE, ROLE_CAPABLE_AUTHZ, ROLE_ANNOTATION_RE, SEC_CONFIG_HINT_RE, MATCHER_RE, ACCESS_AFTER_RE, ANY_REQUEST_RE, offsetOfLine, readBalanced2, stringLiterals, antMatches, hasAdminRoleAnnotation, classHeaderOf, memberWindow, annotationStance, accessKind, collectFilterConfig, filterStanceFor, combineProtection, publicNote, item6, auditAdminSurface, CLOUD_ACL_SPEC, MAX_EVIDENCE9, lineOf8, PUBLIC_ACL_PATTERNS, finalizeHits4, collectCannedAclHits, EFFECT_ALLOW_RE, WILDCARD_PRINCIPAL_RE, S3_ACTION_RE, enclosingObject, collectBucketPolicyHits, evidence6, item7, scanCloudStorageAcl, ACTUATOR_SPEC, MAX_EVIDENCE10, CONFIG_FILE_RE, SENSITIVE_ACTUATOR_ENDPOINTS, lineOf9, indentOf, isBlankOrComment, splitEndpoints, classifyExposure, exposureNote, H2_NOTE, findChildKey, collectListItems, collectExposureHits, collectH2Hits, finalizeHits5, evidence7, item8, scanActuatorExposure, BACKUP_FILE_SPEC, BACKUP_FILE_GLOBS, BACKUP_FILE_RE, SENSITIVE_BASE_RE, MAX_EVIDENCE11, stripBackupSuffix, classify2, evidence8, scanBackupFiles, CROSSDOMAIN_SPEC, CROSSDOMAIN_GLOBS, MAX_EVIDENCE12, lineOf10, PERMISSIVE_PATTERNS, collectHits, evidence9, scanCrossDomainPolicy, CLIENT_INFO_SPEC, ANGULAR_CONFIG_GLOBS, MAX_EVIDENCE13, lineOf11, asRecord, sourceMapEnabled, buildConfigurations, scanConfigFile, evidence10, item9, scanClientInfoLeak, SENSITIVE_FILE_SPEC, SENSITIVE_FILE_GLOBS, SENSITIVE_FILE_RE, PEM_TEXT_RE, PRIVATE_KEY_HEADER_RE, MAX_EVIDENCE14, classify22, evidence11, scanSensitiveFiles, INSECURE_TRANSPORT_SPEC, ENVIRONMENT_FILE_RE, MAX_EVIDENCE15, lineOf12, extractStringLiterals, HTTP_URL_RE, HTTPS_PRESENCE_RE, isExcludedHost, TEMPLATE_FILE_RE, scanInsecureFormSubmission, isTestPath, scanExternalCleartextLinks, JAVA_FILE_RE, CLEARTEXT_JAVA_CLIENT_RE, scanJavaCleartextClients, scanInsecureTransport, WEBSOCKET_SPEC, MAX_EVIDENCE16, WS_URL_RE, WSS_PRESENCE_RE, scanWebSocketSecurity, authFillKey, createStubAuthFillResolver, buildAuthFillMap, ALG_TO_HASH, SIGNING_KEY_LINE, ENV_PLACEHOLDER, lineOf13, cleanValue, discoverJwtSigningKeys, b64url, b64urlStr, signingKeyBytes, mintJwt, DEFAULT_JHIPSTER_CLAIMS, RECIPE_NOTE, DECODE_ONLY_NOTE, jarKeysToSigningKeys, sha256Hex, buildRuntimeAuthRecipe, mintTokenFromRecipe, DEFAULT_TTL_SECONDS, commandsFor, credentialFor, runtimeAuthSeedDeviation, runtimeAuthSeedDecodeOnlyDeviation, planFor, buildRuntimeAuthSeedPlan, DEFAULT_TIMEOUT_MS, CRLF, encodeResp, identify, readReply, applyRuntimeAuthSeed, describeShape, resolveRuntimeAuthHypothesis, THREW, createStubRuntimeAuthHypothesisResolver, dataSeedKey, describeShape2, THREW2, resolveRuntimeDataSeedHypothesis, createStubRuntimeDataSeedResolver, buildDataSeedPlan, buildApiCreateSeedPlan, dataSeedEndpointSummaries, IDEMPOTENT_INSERT, BACKSLASH_IS_ESCAPE, escapeSqlString, sqlLiteral, assertIdentifier, renderDataSeedSql, SEED_AUDIT_SENTINEL, AUDIT_FIELD_RE, CLASS_DECL_RE, TABLE_RE, EXTENDS_RE, NULLABLE_FALSE_RE, LENGTH_RE, stripJavaComments, group, detectSeedAuditColumns, applySeedAuditColumns, seedAuditAddedColumns, OBJECT_SEED_BASELINE_KEY, OBJECT_SEED_BASELINE_CONTENT_BASE64, PENTEST_CANARY_BUCKET, MAX_DERIVED_TARGETS, MAX_DERIVED_EVIDENCE, CONFIG_PATH_RE, BUCKET_KEY_RE, LINE_RE, PLACEHOLDER_RE, ENC_PREFIX_RE, BOOLEAN_VALUE_RE, HAS_LOWERCASE_RE, canonicalKey, cleanValue2, resolveValue, referencesToken, deriveObjectStoreSeedTargets, renderObjectStoreSeedTsv, REACHABILITY_MANIFEST_SCHEMA_VERSION, MANIFEST_NOTE, SCALAR_JAVA_TYPES, baseTypeName, seedForParam, METHOD_INTENT, buildHint, buildReachabilityManifest, norm, dirOf, baseName, isMavenPom, isGradleBuild, stripXmlComments, isAncestorDir, normModulePath, selectRunnableModule, PACKAGE_DECL, BOOT_CLASS, posix22, detectSpringBootClass, BASE_CONFIG_RE, PROFILE_CONFIG_RE, HARNESS_PORT, KEY_LINE_RE, yamlEntries, emptyKeys, isConfigYaml, profileRank, declaresDatasource, detectDatasourceProfileBlocker, detectProfileCompositionBlocker, detectServerPortBlocker, XML_COMMENT_RE, INCLUDE_RE, CREATE_TABLE_RE, ALTER_TARGET_RE, matchAllGroups, detectUnrunnableMigrationBlocker, detectPolicyBootBlockers, composeSuggested, BINDABLE_NAME_RE, YAML_KEY_RE, PROPS_KEY_RE, configValueOf, rawTokensOf, MARK, AUTHORITY_LIKE_RE, shapeInAuthority, nextOf, shapeInPath, shapeAt, parseConfigValue, renderTemplate, DIALECT_SPECS, JDBC_URL_PATTERNS, DRIVER_PATTERNS, isConfigFile, isBuildFile, dialectsMatching, resolveDialect, DDL_AUTO_CREATE_RE, FLYWAY_RE, LIQUIBASE_RE, resolveSchemaProvisioning, detectSchemaProvisioning, detectDbTier, DB_SIDECAR_PORT, DISPOSABLE_DB, dbSidecarEnv, buildDbSidecarSpec, PROFILE_GATED_JAR_BEANS, JHIPSTER_PROFILE_CONSTANTS, isJava, CLASS_DECL_RE2, PROFILE_ANNOTATION_RE, CONDITIONAL_ANNOTATION_RE, CONFIG_ANNOTATION_RE, readProfileAnnotation, declarationHead, braceMatch, lineAt, parsedClasses, simpleTypeName2, parseParams, beanMethods, collectProducers, detectUngatedProfileDependencies, ungatedProfileDeviationText, STANDALONE_BOOT_PROFILE, ENTITY_SCHEMA_GAPS, NOTE, isConfigFile2, leafKey, indentOf2, fullPathFor, usesJpa, KAFKA_BUILD_RE, KAFKA_CONFIG_RE, STREAM_BUILD_RE, STREAM_CONFIG_RE, declaresKafka, declaresStreamBinder, hasPinnedListenerAutoStartup, ENDPOINT_PROPERTY_RULES, ENDPOINT_VALUE_RE, CLUSTER_TOPOLOGY_RULES, literalDatabaseOf, resolveSchemaResolution, buildStandaloneBootProfile, runtimeEnvKeyFor, A_SENTINEL, ENC_SENTINEL, isEndpointShaped, isEndpointPropertyPath, hasToken, dummyFor, RELAXED_ENV, envKeyFor, buildSidecars, renderSidecar, identifyByName, PATH_KINDS, PATH_LEAF_ROLES, identifyByPath, roleFromShape, shapedDummy, resolveSlot, resolvePlaceholder, encSentinelFor, SHAPE_PRECEDENCE, strongerShape, buildBootResolution, CONFIG_ENTRY_RE, SKIPPED_ENTRY_RE, XML_COMMENT_RE2, SYSTEM_PATH_RE, declaredSystemJarEntries, declaredSystemJarPaths, readCentralDirectory, readEntryBytes, readEntryText, languageFor, detectMissingSystemJars, readJarConfigFiles, listJarClassNames, MIN_CONSTANT_LEN, MAX_CONSTANT_LEN, MAX_CONSTANTS_PER_CLASS, NOISE_CONSTANT_RE, parseClassConstants, constantRank, readJarClassConstants, collectDependencyClassConstants, collectDependencyClassNames, collectDependencyConfigFiles, JWT_CONTEXT_MARKER_RE, BASE64_SHAPE_RE, MIN_BASE64_KEY_CHARS, MAX_BASE64_KEY_CHARS, decodedByteLength, readJarJwtKeyCandidates, collectJwtKeyCandidates, JWT_FACADE_RE, JWT_DECODE_CALL_RE, JWT_VERIFY_MARKER_RE, readJarDecodeOnlyEvidence, collectDecodeOnlyEvidence, EOCD_SIGNATURE, CENTRAL_SIGNATURE, EOCD_SEARCH_WINDOW, MAX_COMPRESSION_RATIO, MAX_UNCOMPRESSED_BYTES, MAX_ENTRIES, fail, isUnsafeName, readArchive, readArchiveEntryText, SOURCE_EXTENSIONS, extensionOf, baseNameOf, XML_COMMENT_RE3, isAggregatorPom, declaresParentPath, declaresSystemPaths, resolveAgainst, preflightArchive, SKIP_DIRS, MAX_FILE_BYTES, MAX_PARENT_DEPTH, toPosix2, isFile, walk, XML_COMMENT_RE4, RELATIVE_PATH_RE, SYSTEM_PATH_RE2, PARENT_BLOCK_RE, EMPTY_RELATIVE_PATH_RE, readPom, expandBasedir, planServicePackage, CRC_TABLE, crc32, writePackageZip, SIDECAR_IMAGES, HARNESS_PLAN_SCHEMA_VERSION, isConfigFile3, isBuildFile2, stripComments, SERVICE_DEPS, detectDatabaseDependency, detectServiceDependencies, detectHarnessDependencies, AUTO_CONFIGURED_LISTENER_FACTORY, KAFKA_LISTENER_ARGS_RE, LISTENER_PIN_RE, LISTENER_FACTORY_RE, SELF_OFF_FACTORY_BEAN_RE, SET_AUTO_STARTUP_FALSE_RE, classifyKafkaBootPath, buildHarnessPlan, applyKafkaBrokerCoherence, RUNTIME_PLAN_SCHEMA_VERSION, PLAN_NOTE, describeSidecar, buildSteps, buildRuntimeBringUpPlan, RUNTIME_OVERLAY_FILE, RUNTIME_COMPOSE_FILE, RUNTIME_GUIDE_FILE, RUNTIME_BOOT_ENV_FILE, SIDECAR_IMAGE, REDIS_CLUSTER_COMMAND, renderNestedYaml, renderOverlay, publishLine, renderCompose, renderGuide, renderBootEnv, generateRuntimeArtifacts, SUBMISSION_REQUIREMENTS_SCHEMA_VERSION, MAX_EVIDENCE17, NOTE2, capEvidence, totalSuffix, blockerEvidence, groupBy, packagingRequirements, secretRequirements, POLICY_KINDS, policyRequirements, infrastructureRequirements, authRequirements, seedRequirements, TIER_ORDER, buildSubmissionRequirements, renderSubmissionRequirements, REJECT_SIDECAR, applyRuntimeInput, DESER_SPEC, MAX_EVIDENCE18, lineOf14, UNSAFE_PATTERNS, collectHits2, SAFE_VALIDATOR_RE, firstSafeValidator, evidence12, item10, scanUnsafeDeserialization, WEAK_RANDOM_SPEC, MAX_EVIDENCE19, lineOf15, WEAK_RNG_PATTERNS, SECURITY_ID_RE, statementAround, COOKIE_SINK_MAX_HOPS, namesCarrying, reachesCookie, collectHits3, SECURE_RANDOM_RE, firstSecureRandom, evidence13, item11, scanWeakSecureRandom, POSTMESSAGE_SPEC, MAX_EVIDENCE20, lineOf16, WINDOW_LISTENER_PATTERNS, ORIGIN_RE, isFrontend, listenersIn, evidence14, item12, scanPostMessageOrigin, XXE_SPEC, MAX_EVIDENCE21, lineOf17, XML_PARSER_PATTERNS, HARDENING_RE, parsersIn, evidence15, item13, scanXxe, WEAK_TLS_SPEC, MAX_EVIDENCE222, lineOf18, BYPASS_PATTERNS, TLS_SURFACE_RE, bypassesIn, evidence16, item14, scanWeakTls, DOCKERFILE_SPEC, DOCKERFILE_RE, DOCKERFILE_GLOBS, isLoopback, auditDockerfileDependencyConfusion, auditDockerfileContent, scanDockerfile, HOST_HEADER_SPEC, MAX_EVIDENCE23, lineOf20, HOST_PATTERNS, collectHits5, evidence18, item16, scanHostHeader, CHECKLIST_ID2, CONTROL_ID2, TITLE2, evidenceOf3, item17, VALUE_ANNOTATION_RE, FIELD_AFTER_VALUE_RE, LIFETIME_TOKEN_RE, tokenize, hasOtpToken, TIME_UNIT_RE, NAME_UNIT_HINTS, TO_SECONDS, lineOf21, isOtpLifetimeName, configRank, inconclusive, scanOtpPolicy, PASSWORD_POLICY_SPEC, MAX_EVIDENCE24, lineOf22, precedingBlock3, PASSWORD_NAME_RE, NOT_A_SECRET_RE, isPasswordName, STRING_DECL_RE, SIZE_MIN_RE, ANNOTATION_IN_BLOCK_RE, LENGTH_CHECK_RE, CONSTRAINT_VALIDATOR_RE, ANNOTATION_DECL_RE, STRING_LITERAL_RE, QUANT_MIN_RE, POLICY_SURFACE_PATTERNS, ACCOUNT_SURFACE_RE, baseName2, isAccountSurface, collectCustomConstraintMins, sitesIn, firstUsageIndex, pointersIn, dedupeSort, evidenceOf4, item18, policyNote, scanPasswordPolicy, SPEC, MAX_EVIDENCE25, AUTH_SURFACE_RE, ACCOUNT_EXISTENCE_RE, PASSWORD_ONLY_RE, COMBINED_RE, STRING_LITERAL_RE2, lineOf23, scanAuthFile, dedupeSort2, evidenceOf5, item19, scanAccountEnumeration, SPEC2, MAX_EVIDENCE26, LOGOUT_ENDPOINT_RE, LOGOUT_MENTION_RE, INVALIDATION_PATTERNS, lineOf24, invalidationHits, dedupeSort3, evidenceOf6, item20, scanLogoutInvalidation, SPEC3, MAX_EVIDENCE27, OTP_ISSUE_RE, OTP_MENTION_RE, THROTTLE_PATTERNS, lineOf25, firstMatch2, dedupeSort4, evidenceOf7, item21, scanOtpThrottle, MAX_EVIDENCE28, REST_TEMPLATE_CALL_RE, NEW_URL_RE, URL_TAIL_RE, URI_TAIL_RE, OPEN_CONNECTION_RE, SIGNALS, lineOf26, scanSsrfEndpointHints, SPEC4, MAX_EVIDENCE29, HARD_MUTATION_HANDLER_RE, DIRECT_WRITE_RE, DELEGATION_WRITE_RE, TXN_RE, READ_ONLY_TXN_RE, offsetOfLine2, insideLiteral, extractHandlerBody, braceMatchedBlock, signatureRegion, confirmWrite, dedupeSort5, evidenceOf8, item22, scanStateChangingGet, KEY_MANAGEMENT_SPEC, JAVA_FILE_RE2, CONFIG_FILE_RE2, EMPTY_SECRET_KEY_SPEC_RE, EMPTY_KEY_VAR_RE, scanEmptyEncryptionKeys, MFA_AUTH_SPEC, JAVA_FILE_RE3, CONFIG_FILE_RE3, AUTH_SURFACE_RE2, MFA_INDICATORS_RE, MFA_VERIFY_ENDPOINT_RE, SSO_INDICATORS_RE, isTestPath2, isNonSiteLine, scanMfaAuth, PASSWORD_EXPIRY_SPEC, JAVA_FILE_RE4, CONFIG_FILE_RE4, USER_DETAILS_RE, HARDCODED_CREDENTIALS_NON_EXPIRED_RE, ACTIVE_EXPIRY_CHECK_RE, isTestPath3, scanPasswordExpiryPolicy, SETTER_RE, HTTP_STATUS_RECEIVER, HTTP_STATUS_ARG, CONSTANT_ARG, ENUM_ARG, LOADS_EXISTING, ENTITY_DECL_RE, PRINCIPAL_RE, STATE_NOUN, escapeRegExp, stateReadBefore, hasSameReceiverStateReadBefore, hasCopySourceStateReadBefore, CONSTRUCTED_AS_RE, loadedTypesIn, receiverOriginOf, lineOf27, methodsOf, isJava2, isControllerPath, scanStateTransitionSites, MAX_EVIDENCE30, SEVERITY_ORDER2, SCORE_FLOOR, asRecord2, asString, stripMountPrefix, severityFromTags, field, parseScaReport, effectiveScore, passesThreshold, distinctPairs, bySeverityThenName, evidenceOf9, countBySeverity, provenance, foldScaReport, BRUTE_FORCE_SPEC, MAX_EVIDENCE31, lineOf28, AUTH_CONTEXT_RE, LIMIT_NAME_RE, MAX_VALUE_ASSIGN_RE, MECHANISM_PATTERNS, failOpenHits, mechanismHits, dedupeSort6, evidenceOf10, item23, scanBruteForceProtection, TS_LANGS, MOUNT_ROOT, MOUNT_ANY, TS_EXT_CANDIDATES, MAX_CHAIN_DEPTH, MAX_REEXPORT_DEPTH, UNRESOLVED_PATH, keyOf, applyRouteConfigOverrides, CLIENT_CLASSES, MANUAL_DELIVERY_SOURCES, ENC, ROUTE_BASE_PREFIX, BENIGN_PARAM, CLIENT_ORACLE, deliveryFor, jsStr, normFile, camel, urlChunk, buildGoto, manualComment, renderMethod, renderSpec, dedupeRoutes, generateClientVerificationSuite, buildClientVerificationManifest, WSTG, TC16, MANUAL_CHECKLIST_ITEMS, NEEDS_MANUAL_LIMITATION, buildManualChecklistItems, handoffFileName, MAX_SURFACE_SAMPLE, surfaceContext, INFRA_CONTEXT, buildHandoffPackets, OBJECT_STORE_PROBE_SINKS, GENERATED_PACKAGE, SERVER_CLASSES, BOOLEAN_BLIND_CLASSES, BOOLEAN_BLIND_PAIRS, CLASS_CANARY, COMMAND_CANARY, VALIDATION_REJECT_CLASSES2, CANON_HELPER, CLASS_ORACLE, javaStr, SSRF_BASELINE_WORKBOOK_ENTRIES, SSRF_BASELINE_WORKBOOK_HELPER, BENIGN_SEED, BUCKET_BENIGN_SEED, benignSeedFor, companionBenignSeed, renderAuthSuffix, RUNTIME_AUTH_SUFFIX, renderRuntimeAuthHelper, pascal, camel2, verificationTestClassName, identChunk, fillPath, companionCalls, ssrfPayloadPath, requestExpr, isVerifiable, SERVER_SKIP_REASON, renderBooleanBlind, renderCanary, isObjectStoreProbeSink, OBJECT_STORE_REJECT_CATCH_LINES, wrapObjectStoreAttackGuard, wrapObjectStoreEvidenceAttackGuard, resolveAuth, renderMethod2, renderEvidenceMethod, renderEvidenceHelpers, renderTestcontainersDbTierFields, renderExternalDbTierFields, javaSeedValue, renderSeedMethod, renderApiCreateSeedMethod, renderClass, toManifestEntries, generateVerificationSuite, buildVerificationManifest, decodeEntities, attr, stripCdata, childMessage, classify3, parseJUnitXml, simpleClassName, joinKey, DEFAULT_TRUST_TIER, resolveFromEnvelope, ingestVerification, PROVENANCE_DETAIL, applyProvenanceDowngrades, asRecord3, asString2, asBool, asInt, asHttpStatus, SIGNALS2, ATTESTATION_METHODS, parseProvenance, parseOracle, parseEffectBoundary, parseDefenseControl, parseBaseline, parseAttack, parseEvidenceEnvelope, asRecord4, asArray, asString3, asNumber, basename22, specOutcome, walkSuite, parsePlaywrightReport, joinKey2, ingestClientVerification, compareChecklistId, correlateVerification, EMPTY_CORRELATION, notTestedItem, groupDastByChecklist, dastAxisFor, groupClientByChecklist, clientAxisFor, correlateAssessment, ZAP_SCAN_RULES, DEFAULT_DAST_OPTIONS, DAST_PLAN_FILE, DAST_MANIFEST_FILE, DAST_PROBE_SCRIPT_FILE, DAST_API_SEED_SCRIPT_FILE, API_SEED_VAR_PREFIX, PROBE_VICTIM_BUCKET_REF, PROBE_CANARY_OBJECT_REF, PROBE_INJECTION_KINDS, isScannable, skipReason, yamlStr, normMethod, toTarget, SEED_VALUE, SSRF_SEED_VALUE, seedValue, pathInjectionSeed, computeApiSeedVars, allParams, queryString, requestPath, renderRequest, renderPlanYaml, generateDastPlan, buildProbeSpec, buildProbe, buildDastManifest, cmpStr3, compareScenarioRef, compareExecutionTarget, shq, PROBE_SCRIPT_PROLOGUE, PROBE_SCRIPT_EPILOGUE, renderDastProbeScript, shLiteral, API_SEED_PY, renderDastApiSeedScript, HTTP_EVIDENCE_MAX_HEADER_BYTES, HTTP_EVIDENCE_MAX_BODY_BYTES, REDACTION_WINDOW_BYTES, HTTP_REDACTED, SENSITIVE_HEADER_RE, NEVER_SENSITIVE_HEADER_RE, SCHEMED_HEADER_RE, COOKIE_HEADER_RE, COOKIE_ATTRIBUTE_RE, JSON_SECRET_MEMBER_RE, HEADER_LINE_RE, TOKEN_RUN_RE, redactJwtRun, redactJwts, URL_USERINFO_RE, redactInline, redactHeaderValue, redactHeaderBlock, redactBody, looksBinary, cutUtf8, boundedPart, sanitizeHttpMessage, httpStatusOf, RISK_BY_CODE, asString4, firstLine, httpEvidenceOf, parseZapReport, firstLineOf, usableTimestamp, latestMessageInstant, parseZapMessages, pathOf, stripTrailingSlash, pathMatches, methodMatches, injectionMatches, routeMatchesOrUnknown, alertMatchesTarget, queryHasParam, messageMatchesSurface, computeDastCoverage, detailOf, DAST_HTTP_EVIDENCE_MAX_RESOLUTIONS, carriesHttpText, evidenceOf11, ingestDast, SEMGREP_CWE_MAP, asRecord5, asString5, asNonNegativeInteger, compareText2, compareCwe, stringsFrom, cwesFromProperties, messageText, compareFinding, findingKey, ruleMetadata, metadataForResult, locationsOf, findingsFromRun, parseSemgrepSarif, compareChecklistId2, unmatchedKey, ingestSemgrep, CHECKLIST_ID3, CONTROL_ID3, MAX_EVIDENCE322, OWNER_SCOPED_FINDER, REPOSITORY_DECL, lineOf29, fieldNameFor, collectOwnerScopedRepositories, scanIdor, CHECKLIST_ID4, CONTROL_ID4, MAX_EVIDENCE33, CONTROLLER, MULTIPART_PARAM, ALLOWLIST, CONTENT_SNIFF, lineOf30, collectUploadHandlers, firstMatch3, scanUploadValidation, CHECKLIST_ID5, CONTROL_ID5, MAX_EVIDENCE34, SECRET_KEY_LINE, SELF_IDENTIFYING_KEYS, JWT_CONTEXT_RE, PARENT_KEY_LINE, ancestorPath, ENV_PLACEHOLDER2, NON_PROD_PROFILE, CONFIG_FILE, lineOf31, byFileLine2, collectSecrets, scanJwtSecret, DEVTOOLS_SPEC, BUILD_FILE_RE, auditPomXmlDevTools, auditGradleDevTools, auditBuildFile, scanDevTools, PASSWORD_AUTOCOMPLETE_SPEC, HTML_TEMPLATE_FILE_RE, SECURE_AUTOCOMPLETE_VALUES, isTestPath4, auditPasswordAutocompleteContent, scanPasswordAutocomplete, SYSTEM_INFO_LEAK_SPEC, JAVA_FILE_RE5, isTestPath5, PRINT_STACK_TRACE_RE, SYSTEM_PRINT_EXCEPTION_RE, auditJavaErrorDisclosure, scanSystemInfoLeak;
|
|
11606
|
+
var createCompositeParser, SUPPORTED, createTextParser, requireFromHere, grammarCache, parserInitialized, initParser, resolveGrammarPath, loadGrammar, LANGUAGE_TO_GRAMMAR, SUPPORTED2, createTreeSitterParser, asTreeSitterTree, SUPPORTED3, scriptKindFor, createTsMorphParser, createParser, TS_LANGUAGES, EXTENSIONS, TS_SOURCE_EXTENSIONS_BY_RUNTIME_EXT, scriptKindFor2, normalizeRelativePath, candidatePaths, normalizeConfigPath, stripJsonComments, loadTsConfigResolver, matchPathPattern, applyPathTarget, resolveAliasModule, resolveModule, aliasIfDifferent, exportedSymbols, expressionRootName, addSymbol, compareText, variableBindingNames, importEqualsSpecifier, extractSymbols, fingerprintFor, createTsAstDependencyGraphBuilder, isTsLike, debug, warn, tryLoad, trySave, createIncrementalAstGraphBuilder, SOURCES, SINKS, SANITIZERS, DEFAULT_TS_TAINT_TABLES, JAVA_SOURCES, JAVA_SINKS, JAVA_SANITIZERS, DEFAULT_JAVA_TAINT_TABLES, EMPTY_SUMMARY, paramSentinel, PARAM_SENTINEL_RE, MAX_CROSS_FILE_DEPTH, TYPE_DECL_NODES, indexCache, SCOPE_BOUNDARY, SCOPE_BOUNDARY2, TYPE_DECL, STRING_PASSTHROUGH, ARG_PASSTHROUGH, CONTAINER_ELEMENT, BUILDER_APPENDERS, COLLECTION_MUTATORS, RECEIVER_FOLD_MUTATORS, CONDITIONAL_CONSTRUCT, EMPTY_SUMMARY2, paramSentinel2, PARAM_SENTINEL_RE2, MAX_CROSS_METHOD_DEPTH, SANITIZE_CALL, BYPASS_CALL, PREFIX_GATE, MAX_VALUE_HOPS, SOURCE_PATTERNS, maskJavaComments, maskedCorpusCache, maskJavaFiles, MAPPING_ANNOTATIONS, PARAM_ANNOTATIONS, AUTHZ_ANNOTATIONS, VALIDATION_ANNOTATIONS, annotationScanner, TYPE_DECL2, MODIFIER, METHOD_NAME, LEADING_ANNOTATION, simpleName, lineOf, readBalanced, annotationArgs, firstStringLiteral, readMappingPath, readMappingMethod, joinPaths, skipToDeclaration, isTypeDeclaration, splitParams, parseParam, readAuthAnnotations, ROLE_ANNOTATIONS, stripRolePrefix, readAuthRoles, precedingBlock, readClassContext, extractFromFile, extractHttpEndpoints, findEnclosingEndpoint, SINK_ATTACKS, AI_TRIAGE_ATTACK_ALIASES, SOURCE_KIND, kindsFromSources, deriveAuthContext, resolveCompanionParams, resolveInjectionPoint, buildServerRequest, buildClientRequest, generateAttackScenario, UNASSESSED_CATALOG, BY_ID, buildUnassessedItems, INJECTION_LANGUAGES, TIER_A_INJECTION_ITEMS, CONFIRMED_LIMITATION, INCONCLUSIVE_LIMITATION, evidenceFrom, byFileLine, CHECKLIST_VERDICT_RANK, mergeEqualRank, dedupeByChecklistId, scenarioByFileLine, PENTEST_CHECKLIST_TOTAL, DECLARED_CHECKLIST_IDS, buildChecklistCoverage, buildCoverage, assembleAssessment, MAX_EVIDENCE3, REVIEW_SIGNAL_MAP, asJsonRecord, readReviewFinding, parseReviewReport, evidenceOf, sortEvidence, foldReviewSignals, MAX_EVIDENCE22, AUTHORIZATION_RISK_EVIDENCE, MASS_ASSIGNMENT_EVIDENCE, OWNERSHIP_SCOPE_EVIDENCE, STATE_TRANSITION_EVIDENCE, AI_SIGNAL_MAP, readPerRule, parseAiReviewReport, evidenceOf2, sortEvidence2, scopeClauseOf, provenanceOf, skipReasonOf, anchorResolves, anchorOf, unresolvableCitationClause, citationGateClause, citationTargetNoun, anchorAccepts, foldAiSignals, IMPORT_LINE_RE, isImportOrPackageLine, CSRF_SPEC, CORS_SPEC, HEADERS_SPEC, STACKTRACE_SPEC, MESSAGE_SPEC, COOKIE_SPEC, SESSION_FIXATION_SPEC, SESSION_TIMEOUT_SPEC, AUTH_CACHE_SPEC, lineOf2, SECURITY_CONFIG_RE, CSRF_DISABLE_RE, CORS_WILDCARD_RE, CROSS_ORIGIN_BARE_RE, ALLOW_CREDENTIALS_RE, CORS_EXPLICIT_ORIGIN_RE, CORS_ANY_RE, HEADERS_DISABLE_RES, HEADERS_CONFIGURED_RE, CSP_CONFIGURED_RE, STACKTRACE_EXPOSE_RE, STACKTRACE_NEVER_RE, MESSAGE_EXPOSE_RE, MESSAGE_NEVER_RE, COOKIE_CONTEXT_RE, COOKIE_INSECURE_CHECKS, COOKIE_HARDENED_RE, SESSION_FIXATION_DISABLED_RE, CACHE_CONTROL_DISABLE_RE, CACHE_CONTROL_CONFIGURED_RE, SESSION_TIMEOUT_PATH_RE, SESSION_BLOCK_HEADER_RE, SESSION_TIMEOUT_LEAF_RE, YAML_INDENT_RE, control, configEvidence, firstMatch, firstMatchAny, scanCsrf, CORS_ORIGINS_YAML_RE, CORS_CREDENTIALS_YAML_RE, isWildcardOrigins, corsConfigRank, corsOriginHits, scanCors, scanSecurityHeaders, NON_PROD_PROFILE_RE, scanStacktraceExposure, scanErrorMessageExposure, scanCookieAttributes, scanSessionFixation, scanAuthCacheControl, findSessionTimeout, timeoutNeverExpires, timeoutToMinutes, JWT_VALIDITY_RE, NON_PROD_CONFIG_RE, findJwtValidities, hoursOf, judgeJwtValidity, judgeServletTimeout, scanSessionTimeout, scanSecurityConfig, TEST_SOURCE_SET_RE, isTestSourcePath, WEAK_CRYPTO_SPEC, MAX_EVIDENCE32, lineOf3, classifyAlgorithm, GET_INSTANCE_RE, COMMONS_DIGEST_RE, GUAVA_HASHING_RE, SECRET_KEY_SPEC_RE, SHORTHAND_ALGO, collectWeakHits, STRONG_CRYPTO_RE, STRONG_CRYPTO_RE_G, firstStrong, evidence, item, scanWeakCrypto, REGEX_PRECEDING_KEYWORDS, isIdentChar, regexAllowedAt, maskJsComments, maskedCorpusCache2, maskJsFiles, BROWSER_STORAGE_SPEC, MAX_EVIDENCE4, lineOf4, HIGH_SENSITIVITY_RE, TOKEN_FAMILY_RE, classifyStorageKey, VALUE_TOKEN_FAMILY_RE, classifyStorageValue, keyToken, SET_ITEM_RE, BRACKET_ASSIGN_RE, STORAGE_USE_RE, IDB_CONTEXT_RE, LOCALFORAGE_SET_RE, IDB_STORE_WRITE_RE, collectStorageHits, collectIndexedDbHits, finalizeHits, firstStorageUse, evidence2, item2, scanSensitiveBrowserStorage, AT_REST_SPEC, MAX_EVIDENCE5, lineOf5, PWD_GETTER, PWD_EQUALS_RECEIVER_RE, PWD_EQUALS_ARG_RE, collectPasswordComparisonHits, SENSITIVE_FIELD_NAMES, FIELD_DECL_RE, FIELD_PROTECTED_RE, precedingBlock2, collectPlaintextFieldHits, finalizeHits2, PROTECTION_RE, firstProtection, AT_REST_SURFACE_RE, evidence3, item3, scanSensitiveDataAtRest, PADDING_ORACLE_SPEC, MAX_EVIDENCE6, lineOf6, GET_INSTANCE_RE2, collectCbcHits, BAD_PADDING_CATCH_RE, collectBadPaddingHits, finalizeHits3, AEAD_RE, firstAead, CIPHER_SURFACE_RE, evidence4, item4, scanPaddingOracle, LOGGING_SPEC, MAX_EVIDENCE7, lineOf7, JAVA_LOG_CALL_RE, JAVA_CONSOLE_CALL_RE, JS_CONSOLE_CALL_RE, LOG_SURFACE_RE, stripStringLiterals, SECRET_RE, PII_RE, PROTECTED_TAIL_RE, findSensitiveToken, collectSensitiveContainers, findSensitiveArgument, findSensitiveOutput, firstLogSurface, evidence5, item5, scanSensitiveLogging, CHECKLIST_ID, CONTROL_ID, TITLE, CWE, MAX_EVIDENCE8, ADMIN_PATH_RE, ADMIN_CONTROLLER_RE, isAdminEndpoint, ADMIN_ROLE_RE, ROLE_CAPABLE_AUTHZ, ROLE_ANNOTATION_RE, SEC_CONFIG_HINT_RE, MATCHER_RE, ACCESS_AFTER_RE, ANY_REQUEST_RE, offsetOfLine, readBalanced2, stringLiterals, antMatches, hasAdminRoleAnnotation, classHeaderOf, memberWindow, annotationStance, accessKind, collectFilterConfig, filterStanceFor, combineProtection, publicNote, item6, auditAdminSurface, CLOUD_ACL_SPEC, MAX_EVIDENCE9, lineOf8, PUBLIC_ACL_PATTERNS, finalizeHits4, collectCannedAclHits, EFFECT_ALLOW_RE, WILDCARD_PRINCIPAL_RE, S3_ACTION_RE, enclosingObject, collectBucketPolicyHits, evidence6, item7, scanCloudStorageAcl, ACTUATOR_SPEC, MAX_EVIDENCE10, CONFIG_FILE_RE, SENSITIVE_ACTUATOR_ENDPOINTS, lineOf9, indentOf, isBlankOrComment, splitEndpoints, classifyExposure, exposureNote, H2_NOTE, findChildKey, collectListItems, collectExposureHits, collectH2Hits, finalizeHits5, evidence7, item8, scanActuatorExposure, BACKUP_FILE_SPEC, BACKUP_FILE_GLOBS, BACKUP_FILE_RE, SENSITIVE_BASE_RE, MAX_EVIDENCE11, stripBackupSuffix, classify2, evidence8, scanBackupFiles, CROSSDOMAIN_SPEC, CROSSDOMAIN_GLOBS, MAX_EVIDENCE12, lineOf10, PERMISSIVE_PATTERNS, collectHits, evidence9, scanCrossDomainPolicy, CLIENT_INFO_SPEC, ANGULAR_CONFIG_GLOBS, MAX_EVIDENCE13, lineOf11, asRecord, sourceMapEnabled, buildConfigurations, scanConfigFile, evidence10, item9, scanClientInfoLeak, SENSITIVE_FILE_SPEC, SENSITIVE_FILE_GLOBS, SENSITIVE_FILE_RE, PEM_TEXT_RE, PRIVATE_KEY_HEADER_RE, MAX_EVIDENCE14, classify22, evidence11, scanSensitiveFiles, INSECURE_TRANSPORT_SPEC, ENVIRONMENT_FILE_RE, MAX_EVIDENCE15, lineOf12, extractStringLiterals, HTTP_URL_RE, HTTPS_PRESENCE_RE, isExcludedHost, TEMPLATE_FILE_RE, scanInsecureFormSubmission, isTestPath, scanExternalCleartextLinks, JAVA_FILE_RE, CLEARTEXT_JAVA_CLIENT_RE, scanJavaCleartextClients, scanInsecureTransport, WEBSOCKET_SPEC, MAX_EVIDENCE16, WS_URL_RE, WSS_PRESENCE_RE, scanWebSocketSecurity, authFillKey, createStubAuthFillResolver, buildAuthFillMap, ALG_TO_HASH, SIGNING_KEY_LINE, ENV_PLACEHOLDER, lineOf13, cleanValue, discoverJwtSigningKeys, b64url, b64urlStr, signingKeyBytes, mintJwt, DEFAULT_JHIPSTER_CLAIMS, RECIPE_NOTE, DECODE_ONLY_NOTE, jarKeysToSigningKeys, sha256Hex, buildRuntimeAuthRecipe, mintTokenFromRecipe, DEFAULT_TTL_SECONDS, commandsFor, credentialFor, runtimeAuthSeedDeviation, runtimeAuthSeedDecodeOnlyDeviation, planFor, buildRuntimeAuthSeedPlan, DEFAULT_TIMEOUT_MS, CRLF, encodeResp, identify, readReply, applyRuntimeAuthSeed, describeShape, resolveRuntimeAuthHypothesis, THREW, createStubRuntimeAuthHypothesisResolver, dataSeedKey, describeShape2, THREW2, resolveRuntimeDataSeedHypothesis, createStubRuntimeDataSeedResolver, buildDataSeedPlan, buildApiCreateSeedPlan, dataSeedEndpointSummaries, IDEMPOTENT_INSERT, BACKSLASH_IS_ESCAPE, escapeSqlString, sqlLiteral, assertIdentifier, renderDataSeedSql, SEED_AUDIT_SENTINEL, AUDIT_FIELD_RE, CLASS_DECL_RE, TABLE_RE, EXTENDS_RE, NULLABLE_FALSE_RE, LENGTH_RE, stripJavaComments, group, detectSeedAuditColumns, applySeedAuditColumns, seedAuditAddedColumns, OBJECT_SEED_BASELINE_KEY, OBJECT_SEED_BASELINE_CONTENT_BASE64, PENTEST_CANARY_BUCKET, MAX_DERIVED_TARGETS, MAX_DERIVED_EVIDENCE, CONFIG_PATH_RE, BUCKET_KEY_RE, LINE_RE, PLACEHOLDER_RE, ENC_PREFIX_RE, BOOLEAN_VALUE_RE, HAS_LOWERCASE_RE, canonicalKey, cleanValue2, resolveValue, referencesToken, deriveObjectStoreSeedTargets, renderObjectStoreSeedTsv, REACHABILITY_MANIFEST_SCHEMA_VERSION, MANIFEST_NOTE, SCALAR_JAVA_TYPES, baseTypeName, seedForParam, METHOD_INTENT, buildHint, buildReachabilityManifest, norm, dirOf, baseName, isMavenPom, isGradleBuild, stripXmlComments, isAncestorDir, normModulePath, selectRunnableModule, PACKAGE_DECL, BOOT_CLASS, posix22, detectSpringBootClass, BASE_CONFIG_RE, PROFILE_CONFIG_RE, HARNESS_PORT, KEY_LINE_RE, yamlEntries, emptyKeys, isConfigYaml, profileRank, declaresDatasource, detectDatasourceProfileBlocker, detectProfileCompositionBlocker, detectServerPortBlocker, XML_COMMENT_RE, INCLUDE_RE, CREATE_TABLE_RE, ALTER_TARGET_RE, matchAllGroups, detectUnrunnableMigrationBlocker, detectPolicyBootBlockers, composeSuggested, BINDABLE_NAME_RE, YAML_KEY_RE, PROPS_KEY_RE, configValueOf, rawTokensOf, MARK, AUTHORITY_LIKE_RE, shapeInAuthority, nextOf, shapeInPath, shapeAt, parseConfigValue, renderTemplate, DIALECT_SPECS, JDBC_URL_PATTERNS, DRIVER_PATTERNS, isConfigFile, isBuildFile, dialectsMatching, resolveDialect, DDL_AUTO_CREATE_RE, FLYWAY_RE, LIQUIBASE_RE, resolveSchemaProvisioning, detectSchemaProvisioning, detectDbTier, DB_SIDECAR_PORT, DISPOSABLE_DB, dbSidecarEnv, buildDbSidecarSpec, PROFILE_GATED_JAR_BEANS, JHIPSTER_PROFILE_CONSTANTS, isJava, CLASS_DECL_RE2, PROFILE_ANNOTATION_RE, CONDITIONAL_ANNOTATION_RE, CONFIG_ANNOTATION_RE, readProfileAnnotation, declarationHead, braceMatch, lineAt, parsedClasses, simpleTypeName2, parseParams, beanMethods, collectProducers, detectUngatedProfileDependencies, ungatedProfileDeviationText, STANDALONE_BOOT_PROFILE, ENTITY_SCHEMA_GAPS, NOTE, isConfigFile2, leafKey, indentOf2, fullPathFor, usesJpa, KAFKA_BUILD_RE, KAFKA_CONFIG_RE, STREAM_BUILD_RE, STREAM_CONFIG_RE, declaresKafka, declaresStreamBinder, hasPinnedListenerAutoStartup, ENDPOINT_PROPERTY_RULES, ENDPOINT_VALUE_RE, CLUSTER_TOPOLOGY_RULES, literalDatabaseOf, resolveSchemaResolution, buildStandaloneBootProfile, runtimeEnvKeyFor, A_SENTINEL, ENC_SENTINEL, isEndpointShaped, isEndpointPropertyPath, hasToken, dummyFor, RELAXED_ENV, envKeyFor, buildSidecars, renderSidecar, identifyByName, PATH_KINDS, PATH_LEAF_ROLES, identifyByPath, roleFromShape, shapedDummy, resolveSlot, resolvePlaceholder, encSentinelFor, SHAPE_PRECEDENCE, strongerShape, buildBootResolution, CONFIG_ENTRY_RE, SKIPPED_ENTRY_RE, XML_COMMENT_RE2, SYSTEM_PATH_RE, declaredSystemJarEntries, declaredSystemJarPaths, readCentralDirectory, readEntryBytes, readEntryText, languageFor, detectMissingSystemJars, readJarConfigFiles, listJarClassNames, MIN_CONSTANT_LEN, MAX_CONSTANT_LEN, MAX_CONSTANTS_PER_CLASS, NOISE_CONSTANT_RE, parseClassConstants, constantRank, readJarClassConstants, collectDependencyClassConstants, collectDependencyClassNames, collectDependencyConfigFiles, JWT_CONTEXT_MARKER_RE, BASE64_SHAPE_RE, MIN_BASE64_KEY_CHARS, MAX_BASE64_KEY_CHARS, decodedByteLength, readJarJwtKeyCandidates, collectJwtKeyCandidates, JWT_FACADE_RE, JWT_DECODE_CALL_RE, JWT_VERIFY_MARKER_RE, readJarDecodeOnlyEvidence, collectDecodeOnlyEvidence, EOCD_SIGNATURE, CENTRAL_SIGNATURE, EOCD_SEARCH_WINDOW, MAX_COMPRESSION_RATIO, MAX_UNCOMPRESSED_BYTES, MAX_ENTRIES, fail, isUnsafeName, readArchive, readArchiveEntryText, SOURCE_EXTENSIONS, extensionOf, baseNameOf, XML_COMMENT_RE3, isAggregatorPom, declaresParentPath, declaresSystemPaths, resolveAgainst, preflightArchive, SKIP_DIRS, SECRET_FILE_EXACT, SECRET_EXTENSIONS, isSecretOrIgnoredFile, MAX_FILE_BYTES, MAX_PARENT_DEPTH, toPosix2, isFile, walk, XML_COMMENT_RE4, RELATIVE_PATH_RE, SYSTEM_PATH_RE2, PARENT_BLOCK_RE, EMPTY_RELATIVE_PATH_RE, readPom, expandBasedir, planServicePackage, CRC_TABLE, crc32, writePackageZip, SIDECAR_IMAGES, HARNESS_PLAN_SCHEMA_VERSION, isConfigFile3, isBuildFile2, stripComments, SERVICE_DEPS, detectDatabaseDependency, detectServiceDependencies, detectHarnessDependencies, AUTO_CONFIGURED_LISTENER_FACTORY, KAFKA_LISTENER_ARGS_RE, LISTENER_PIN_RE, LISTENER_FACTORY_RE, SELF_OFF_FACTORY_BEAN_RE, SET_AUTO_STARTUP_FALSE_RE, classifyKafkaBootPath, buildHarnessPlan, applyKafkaBrokerCoherence, RUNTIME_PLAN_SCHEMA_VERSION, PLAN_NOTE, describeSidecar, buildSteps, buildRuntimeBringUpPlan, RUNTIME_OVERLAY_FILE, RUNTIME_COMPOSE_FILE, RUNTIME_GUIDE_FILE, RUNTIME_BOOT_ENV_FILE, SIDECAR_IMAGE, REDIS_CLUSTER_COMMAND, renderNestedYaml, renderOverlay, publishLine, renderCompose, renderGuide, renderBootEnv, generateRuntimeArtifacts, SUBMISSION_REQUIREMENTS_SCHEMA_VERSION, MAX_EVIDENCE17, NOTE2, capEvidence, totalSuffix, blockerEvidence, groupBy, packagingRequirements, secretRequirements, POLICY_KINDS, policyRequirements, infrastructureRequirements, authRequirements, seedRequirements, TIER_ORDER, buildSubmissionRequirements, renderSubmissionRequirements, REJECT_SIDECAR, applyRuntimeInput, DESER_SPEC, MAX_EVIDENCE18, lineOf14, UNSAFE_PATTERNS, collectHits2, SAFE_VALIDATOR_RE, firstSafeValidator, evidence12, item10, scanUnsafeDeserialization, WEAK_RANDOM_SPEC, MAX_EVIDENCE19, lineOf15, WEAK_RNG_PATTERNS, SECURITY_ID_RE, statementAround, COOKIE_SINK_MAX_HOPS, namesCarrying, reachesCookie, collectHits3, SECURE_RANDOM_RE, firstSecureRandom, evidence13, item11, scanWeakSecureRandom, POSTMESSAGE_SPEC, MAX_EVIDENCE20, lineOf16, WINDOW_LISTENER_PATTERNS, ORIGIN_RE, isFrontend, listenersIn, evidence14, item12, scanPostMessageOrigin, XXE_SPEC, MAX_EVIDENCE21, lineOf17, XML_PARSER_PATTERNS, HARDENING_RE, parsersIn, evidence15, item13, scanXxe, WEAK_TLS_SPEC, MAX_EVIDENCE222, lineOf18, BYPASS_PATTERNS, TLS_SURFACE_RE, bypassesIn, evidence16, item14, scanWeakTls, DOCKERFILE_SPEC, DOCKERFILE_RE, DOCKERFILE_GLOBS, isLoopback, auditDockerfileDependencyConfusion, auditDockerfileContent, scanDockerfile, HOST_HEADER_SPEC, MAX_EVIDENCE23, lineOf20, HOST_PATTERNS, collectHits5, evidence18, item16, scanHostHeader, CHECKLIST_ID2, CONTROL_ID2, TITLE2, evidenceOf3, item17, VALUE_ANNOTATION_RE, FIELD_AFTER_VALUE_RE, LIFETIME_TOKEN_RE, tokenize, hasOtpToken, TIME_UNIT_RE, NAME_UNIT_HINTS, TO_SECONDS, lineOf21, isOtpLifetimeName, configRank, inconclusive, scanOtpPolicy, PASSWORD_POLICY_SPEC, MAX_EVIDENCE24, lineOf22, precedingBlock3, PASSWORD_NAME_RE, NOT_A_SECRET_RE, isPasswordName, STRING_DECL_RE, SIZE_MIN_RE, ANNOTATION_IN_BLOCK_RE, LENGTH_CHECK_RE, CONSTRAINT_VALIDATOR_RE, ANNOTATION_DECL_RE, STRING_LITERAL_RE, QUANT_MIN_RE, POLICY_SURFACE_PATTERNS, ACCOUNT_SURFACE_RE, baseName2, isAccountSurface, collectCustomConstraintMins, sitesIn, firstUsageIndex, pointersIn, dedupeSort, evidenceOf4, item18, policyNote, scanPasswordPolicy, SPEC, MAX_EVIDENCE25, AUTH_SURFACE_RE, ACCOUNT_EXISTENCE_RE, PASSWORD_ONLY_RE, COMBINED_RE, STRING_LITERAL_RE2, lineOf23, scanAuthFile, dedupeSort2, evidenceOf5, item19, scanAccountEnumeration, SPEC2, MAX_EVIDENCE26, LOGOUT_ENDPOINT_RE, LOGOUT_MENTION_RE, INVALIDATION_PATTERNS, lineOf24, invalidationHits, dedupeSort3, evidenceOf6, item20, scanLogoutInvalidation, SPEC3, MAX_EVIDENCE27, OTP_ISSUE_RE, OTP_MENTION_RE, THROTTLE_PATTERNS, lineOf25, firstMatch2, dedupeSort4, evidenceOf7, item21, scanOtpThrottle, MAX_EVIDENCE28, REST_TEMPLATE_CALL_RE, NEW_URL_RE, URL_TAIL_RE, URI_TAIL_RE, OPEN_CONNECTION_RE, SIGNALS, lineOf26, scanSsrfEndpointHints, SPEC4, MAX_EVIDENCE29, HARD_MUTATION_HANDLER_RE, DIRECT_WRITE_RE, DELEGATION_WRITE_RE, TXN_RE, READ_ONLY_TXN_RE, offsetOfLine2, insideLiteral, extractHandlerBody, braceMatchedBlock, signatureRegion, confirmWrite, dedupeSort5, evidenceOf8, item22, scanStateChangingGet, KEY_MANAGEMENT_SPEC, JAVA_FILE_RE2, CONFIG_FILE_RE2, EMPTY_SECRET_KEY_SPEC_RE, EMPTY_KEY_VAR_RE, scanEmptyEncryptionKeys, MFA_AUTH_SPEC, JAVA_FILE_RE3, CONFIG_FILE_RE3, AUTH_SURFACE_RE2, MFA_INDICATORS_RE, MFA_VERIFY_ENDPOINT_RE, SSO_INDICATORS_RE, isTestPath2, isNonSiteLine, scanMfaAuth, PASSWORD_EXPIRY_SPEC, JAVA_FILE_RE4, CONFIG_FILE_RE4, USER_DETAILS_RE, HARDCODED_CREDENTIALS_NON_EXPIRED_RE, ACTIVE_EXPIRY_CHECK_RE, isTestPath3, scanPasswordExpiryPolicy, SETTER_RE, HTTP_STATUS_RECEIVER, HTTP_STATUS_ARG, CONSTANT_ARG, ENUM_ARG, LOADS_EXISTING, ENTITY_DECL_RE, PRINCIPAL_RE, STATE_NOUN, escapeRegExp, stateReadBefore, hasSameReceiverStateReadBefore, hasCopySourceStateReadBefore, CONSTRUCTED_AS_RE, loadedTypesIn, receiverOriginOf, lineOf27, methodsOf, isJava2, isControllerPath, scanStateTransitionSites, MAX_EVIDENCE30, SEVERITY_ORDER2, SCORE_FLOOR, asRecord2, asString, stripMountPrefix, severityFromTags, field, parseScaReport, effectiveScore, passesThreshold, distinctPairs, bySeverityThenName, evidenceOf9, countBySeverity, provenance, foldScaReport, BRUTE_FORCE_SPEC, MAX_EVIDENCE31, lineOf28, AUTH_CONTEXT_RE, LIMIT_NAME_RE, MAX_VALUE_ASSIGN_RE, MECHANISM_PATTERNS, failOpenHits, mechanismHits, dedupeSort6, evidenceOf10, item23, scanBruteForceProtection, TS_LANGS, MOUNT_ROOT, MOUNT_ANY, TS_EXT_CANDIDATES, MAX_CHAIN_DEPTH, MAX_REEXPORT_DEPTH, UNRESOLVED_PATH, keyOf, applyRouteConfigOverrides, CLIENT_CLASSES, MANUAL_DELIVERY_SOURCES, ENC, ROUTE_BASE_PREFIX, BENIGN_PARAM, CLIENT_ORACLE, deliveryFor, jsStr, normFile, camel, urlChunk, buildGoto, manualComment, renderMethod, renderSpec, dedupeRoutes, generateClientVerificationSuite, buildClientVerificationManifest, WSTG, TC16, MANUAL_CHECKLIST_ITEMS, NEEDS_MANUAL_LIMITATION, buildManualChecklistItems, handoffFileName, MAX_SURFACE_SAMPLE, surfaceContext, INFRA_CONTEXT, buildHandoffPackets, OBJECT_STORE_PROBE_SINKS, GENERATED_PACKAGE, SERVER_CLASSES, BOOLEAN_BLIND_CLASSES, BOOLEAN_BLIND_PAIRS, CLASS_CANARY, COMMAND_CANARY, VALIDATION_REJECT_CLASSES2, CANON_HELPER, CLASS_ORACLE, javaStr, SSRF_BASELINE_WORKBOOK_ENTRIES, SSRF_BASELINE_WORKBOOK_HELPER, BENIGN_SEED, BUCKET_BENIGN_SEED, benignSeedFor, companionBenignSeed, renderAuthSuffix, RUNTIME_AUTH_SUFFIX, renderRuntimeAuthHelper, pascal, camel2, verificationTestClassName, identChunk, fillPath, companionCalls, ssrfPayloadPath, requestExpr, isVerifiable, SERVER_SKIP_REASON, renderBooleanBlind, renderCanary, isObjectStoreProbeSink, OBJECT_STORE_REJECT_CATCH_LINES, wrapObjectStoreAttackGuard, wrapObjectStoreEvidenceAttackGuard, resolveAuth, renderMethod2, renderEvidenceMethod, renderEvidenceHelpers, renderTestcontainersDbTierFields, renderExternalDbTierFields, javaSeedValue, renderSeedMethod, renderApiCreateSeedMethod, renderClass, toManifestEntries, generateVerificationSuite, buildVerificationManifest, decodeEntities, attr, stripCdata, childMessage, classify3, parseJUnitXml, simpleClassName, joinKey, DEFAULT_TRUST_TIER, resolveFromEnvelope, ingestVerification, PROVENANCE_DETAIL, applyProvenanceDowngrades, asRecord3, asString2, asBool, asInt, asHttpStatus, SIGNALS2, ATTESTATION_METHODS, parseProvenance, parseOracle, parseEffectBoundary, parseDefenseControl, parseBaseline, parseAttack, parseEvidenceEnvelope, asRecord4, asArray, asString3, asNumber, basename3, specOutcome, walkSuite, parsePlaywrightReport, joinKey2, ingestClientVerification, compareChecklistId, correlateVerification, EMPTY_CORRELATION, notTestedItem, groupDastByChecklist, dastAxisFor, groupClientByChecklist, clientAxisFor, correlateAssessment, ZAP_SCAN_RULES, DEFAULT_DAST_OPTIONS, DAST_PLAN_FILE, DAST_MANIFEST_FILE, DAST_PROBE_SCRIPT_FILE, DAST_API_SEED_SCRIPT_FILE, API_SEED_VAR_PREFIX, PROBE_VICTIM_BUCKET_REF, PROBE_CANARY_OBJECT_REF, PROBE_INJECTION_KINDS, isScannable, skipReason, yamlStr, normMethod, toTarget, SEED_VALUE, SSRF_SEED_VALUE, seedValue, pathInjectionSeed, computeApiSeedVars, allParams, queryString, requestPath, renderRequest, renderPlanYaml, generateDastPlan, buildProbeSpec, buildProbe, buildDastManifest, cmpStr3, compareScenarioRef, compareExecutionTarget, shq, PROBE_SCRIPT_PROLOGUE, PROBE_SCRIPT_EPILOGUE, renderDastProbeScript, shLiteral, API_SEED_PY, renderDastApiSeedScript, HTTP_EVIDENCE_MAX_HEADER_BYTES, HTTP_EVIDENCE_MAX_BODY_BYTES, REDACTION_WINDOW_BYTES, HTTP_REDACTED, SENSITIVE_HEADER_RE, NEVER_SENSITIVE_HEADER_RE, SCHEMED_HEADER_RE, COOKIE_HEADER_RE, COOKIE_ATTRIBUTE_RE, JSON_SECRET_MEMBER_RE, HEADER_LINE_RE, TOKEN_RUN_RE, redactJwtRun, redactJwts, URL_USERINFO_RE, redactInline, redactHeaderValue, redactHeaderBlock, redactBody, looksBinary, cutUtf8, boundedPart, sanitizeHttpMessage, httpStatusOf, RISK_BY_CODE, asString4, firstLine, httpEvidenceOf, parseZapReport, firstLineOf, usableTimestamp, latestMessageInstant, parseZapMessages, pathOf, stripTrailingSlash, pathMatches, methodMatches, injectionMatches, routeMatchesOrUnknown, alertMatchesTarget, queryHasParam, messageMatchesSurface, computeDastCoverage, detailOf, DAST_HTTP_EVIDENCE_MAX_RESOLUTIONS, carriesHttpText, evidenceOf11, ingestDast, SEMGREP_CWE_MAP, asRecord5, asString5, asNonNegativeInteger, compareText2, compareCwe, stringsFrom, cwesFromProperties, messageText, compareFinding, findingKey, ruleMetadata, metadataForResult, locationsOf, findingsFromRun, parseSemgrepSarif, compareChecklistId2, unmatchedKey, ingestSemgrep, CHECKLIST_ID3, CONTROL_ID3, MAX_EVIDENCE322, OWNER_SCOPED_FINDER, REPOSITORY_DECL, lineOf29, fieldNameFor, collectOwnerScopedRepositories, scanIdor, CHECKLIST_ID4, CONTROL_ID4, MAX_EVIDENCE33, CONTROLLER, MULTIPART_PARAM, ALLOWLIST, CONTENT_SNIFF, lineOf30, collectUploadHandlers, firstMatch3, scanUploadValidation, CHECKLIST_ID5, CONTROL_ID5, MAX_EVIDENCE34, SECRET_KEY_LINE, SELF_IDENTIFYING_KEYS, JWT_CONTEXT_RE, PARENT_KEY_LINE, ancestorPath, ENV_PLACEHOLDER2, NON_PROD_PROFILE, CONFIG_FILE, lineOf31, byFileLine2, collectSecrets, scanJwtSecret, DEVTOOLS_SPEC, BUILD_FILE_RE, auditPomXmlDevTools, auditGradleDevTools, auditBuildFile, scanDevTools, PASSWORD_AUTOCOMPLETE_SPEC, HTML_TEMPLATE_FILE_RE, SECURE_AUTOCOMPLETE_VALUES, isTestPath4, auditPasswordAutocompleteContent, scanPasswordAutocomplete, SYSTEM_INFO_LEAK_SPEC, JAVA_FILE_RE5, isTestPath5, PRINT_STACK_TRACE_RE, SYSTEM_PRINT_EXCEPTION_RE, auditJavaErrorDisclosure, scanSystemInfoLeak;
|
|
11607
11607
|
var init_dist5 = __esm({
|
|
11608
11608
|
"../parsers/dist/index.js"() {
|
|
11609
11609
|
init_dist();
|
|
@@ -21356,8 +21356,43 @@ ${edgePart}`);
|
|
|
21356
21356
|
".idea",
|
|
21357
21357
|
".vscode",
|
|
21358
21358
|
".settings",
|
|
21359
|
-
"deploy-logs"
|
|
21359
|
+
"deploy-logs",
|
|
21360
|
+
".code-sentinel"
|
|
21360
21361
|
]);
|
|
21362
|
+
SECRET_FILE_EXACT = /* @__PURE__ */ new Set([
|
|
21363
|
+
".npmrc",
|
|
21364
|
+
".yarnrc",
|
|
21365
|
+
".netrc",
|
|
21366
|
+
".pypirc",
|
|
21367
|
+
".ds_store",
|
|
21368
|
+
"thumbs.db",
|
|
21369
|
+
"id_rsa",
|
|
21370
|
+
"id_dsa",
|
|
21371
|
+
"id_ecdsa",
|
|
21372
|
+
"id_ed25519"
|
|
21373
|
+
]);
|
|
21374
|
+
SECRET_EXTENSIONS = [
|
|
21375
|
+
".pem",
|
|
21376
|
+
".key",
|
|
21377
|
+
".pfx",
|
|
21378
|
+
".p12",
|
|
21379
|
+
".pkcs12",
|
|
21380
|
+
".keystore",
|
|
21381
|
+
".jks"
|
|
21382
|
+
];
|
|
21383
|
+
isSecretOrIgnoredFile = (fileName2) => {
|
|
21384
|
+
const lower2 = fileName2.toLowerCase();
|
|
21385
|
+
if (lower2 === ".env" || lower2.startsWith(".env.") || lower2.startsWith(".env_")) return true;
|
|
21386
|
+
if (SECRET_FILE_EXACT.has(lower2)) return true;
|
|
21387
|
+
if (lower2.startsWith("id_rsa") || lower2.startsWith("id_dsa") || lower2.startsWith("id_ecdsa") || lower2.startsWith("id_ed25519")) {
|
|
21388
|
+
return true;
|
|
21389
|
+
}
|
|
21390
|
+
if (lower2.startsWith(".code-sentinel.local.")) return true;
|
|
21391
|
+
for (const ext of SECRET_EXTENSIONS) {
|
|
21392
|
+
if (lower2.endsWith(ext)) return true;
|
|
21393
|
+
}
|
|
21394
|
+
return false;
|
|
21395
|
+
};
|
|
21361
21396
|
MAX_FILE_BYTES = 32 * 1024 * 1024;
|
|
21362
21397
|
MAX_PARENT_DEPTH = 8;
|
|
21363
21398
|
toPosix2 = (p) => p.split(sep).join(posix.sep);
|
|
@@ -21381,6 +21416,7 @@ ${edgePart}`);
|
|
|
21381
21416
|
if (SKIP_DIRS.has(item24.name)) continue;
|
|
21382
21417
|
walk(full, repoRoot, out);
|
|
21383
21418
|
} else if (item24.isFile()) {
|
|
21419
|
+
if (isSecretOrIgnoredFile(item24.name)) continue;
|
|
21384
21420
|
try {
|
|
21385
21421
|
if (statSync(full).size > MAX_FILE_BYTES) continue;
|
|
21386
21422
|
} catch {
|
|
@@ -21412,6 +21448,7 @@ ${edgePart}`);
|
|
|
21412
21448
|
const add = (absolutePath) => {
|
|
21413
21449
|
const name = toPosix2(relative(root, absolutePath));
|
|
21414
21450
|
if (name.startsWith("..") || seen.has(name)) return;
|
|
21451
|
+
if (isSecretOrIgnoredFile(basename(absolutePath))) return;
|
|
21415
21452
|
seen.add(name);
|
|
21416
21453
|
entries.push({ name, absolutePath });
|
|
21417
21454
|
};
|
|
@@ -27450,7 +27487,7 @@ ${runtimeAuthHelper}` : ""}
|
|
|
27450
27487
|
asArray = (v) => Array.isArray(v) ? v : [];
|
|
27451
27488
|
asString3 = (v) => typeof v === "string" ? v : void 0;
|
|
27452
27489
|
asNumber = (v) => typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
27453
|
-
|
|
27490
|
+
basename3 = (p) => p.replace(/\\/g, "/").split("/").pop() ?? p;
|
|
27454
27491
|
specOutcome = (spec) => {
|
|
27455
27492
|
let last = null;
|
|
27456
27493
|
for (const testU of asArray(spec.tests)) {
|
|
@@ -27484,7 +27521,7 @@ ${runtimeAuthHelper}` : ""}
|
|
|
27484
27521
|
const specFile = asString3(spec.file) ?? suiteFile;
|
|
27485
27522
|
const { outcome, message, durationMs } = specOutcome(spec);
|
|
27486
27523
|
out.push({
|
|
27487
|
-
file:
|
|
27524
|
+
file: basename3(specFile),
|
|
27488
27525
|
testName,
|
|
27489
27526
|
outcome,
|
|
27490
27527
|
...message !== void 0 ? { message } : {},
|
|
@@ -27512,7 +27549,7 @@ ${runtimeAuthHelper}` : ""}
|
|
|
27512
27549
|
}
|
|
27513
27550
|
return out;
|
|
27514
27551
|
};
|
|
27515
|
-
joinKey2 = (file, testName) => `${
|
|
27552
|
+
joinKey2 = (file, testName) => `${basename3(file)}::${testName}`;
|
|
27516
27553
|
ingestClientVerification = (manifest, cases) => {
|
|
27517
27554
|
const byKey = /* @__PURE__ */ new Map();
|
|
27518
27555
|
for (const c of cases) {
|
|
@@ -29819,19 +29856,25 @@ async function evaluateSliceWithAi(options) {
|
|
|
29819
29856
|
const result = await complete(prompt);
|
|
29820
29857
|
if (!result.ok) {
|
|
29821
29858
|
logger?.warn(`ai-triage executor: provider call FAILED \u2014 ${result.error.message}`);
|
|
29822
|
-
return { vulnerable: false, reason: `L\u1ED7i LLM: ${result.error.message}` };
|
|
29859
|
+
return { status: "error", vulnerable: false, reason: `L\u1ED7i LLM: ${result.error.message}` };
|
|
29823
29860
|
}
|
|
29824
29861
|
const text2 = result.value.text.trim();
|
|
29825
29862
|
if (text2.length === 0) {
|
|
29826
|
-
return { vulnerable: false, reason: "LLM tr\u1EA3 v\u1EC1 ph\u1EA3n h\u1ED3i r\u1ED7ng" };
|
|
29863
|
+
return { status: "error", vulnerable: false, reason: "LLM tr\u1EA3 v\u1EC1 ph\u1EA3n h\u1ED3i r\u1ED7ng" };
|
|
29827
29864
|
}
|
|
29828
29865
|
const parsed = parse2(text2);
|
|
29829
29866
|
if (parsed === null) {
|
|
29830
|
-
return {
|
|
29867
|
+
return {
|
|
29868
|
+
status: "error",
|
|
29869
|
+
vulnerable: false,
|
|
29870
|
+
reason: "Kh\xF4ng ph\xE2n t\xEDch \u0111\u01B0\u1EE3c JSON t\u1EEB ph\u1EA3n h\u1ED3i c\u1EE7a LLM"
|
|
29871
|
+
};
|
|
29831
29872
|
}
|
|
29873
|
+
const isVulnerable = Boolean(parsed.vulnerable);
|
|
29832
29874
|
const endpoint = parseEndpointHint(parsed.endpoint);
|
|
29833
29875
|
const initial = {
|
|
29834
|
-
vulnerable:
|
|
29876
|
+
status: isVulnerable ? "vulnerable" : "safe",
|
|
29877
|
+
vulnerable: isVulnerable,
|
|
29835
29878
|
reason: String(parsed.reason ?? ""),
|
|
29836
29879
|
...endpoint !== void 0 ? { endpoint } : {}
|
|
29837
29880
|
};
|
|
@@ -29860,7 +29903,7 @@ Language guard retry: the previous response contained an empty or English explan
|
|
|
29860
29903
|
} catch (err9) {
|
|
29861
29904
|
const message = err9 instanceof Error ? err9.message : String(err9);
|
|
29862
29905
|
logger?.warn(`ai-triage executor: provider call THREW \u2014 ${message}`);
|
|
29863
|
-
return { vulnerable: false, reason: `L\u1ED7i th\u1EF1c thi LLM: ${message}` };
|
|
29906
|
+
return { status: "error", vulnerable: false, reason: `L\u1ED7i th\u1EF1c thi LLM: ${message}` };
|
|
29864
29907
|
}
|
|
29865
29908
|
}
|
|
29866
29909
|
var OLLAMA_DEFAULT_BASE, NETMIND_DEFAULT_BASE, OPENCODE_GO_DEFAULT_BASE, stripTrailingSlash2, buildLanguageModel, resolveModelOverride, pingTarget, shouldUseRawJsonChat, openAICompatibleChatUrl, REASONING_HEADROOM_TOKENS, NETMIND_MINIMAX_M3_MODEL, NETMIND_SMALL_PROMPT_MAX_CHARS, NETMIND_MEDIUM_PROMPT_MAX_CHARS, NETMIND_SMALL_OUTPUT_TOKENS, NETMIND_MEDIUM_OUTPUT_TOKENS, NETMIND_LARGE_OUTPUT_TOKENS, NETMIND_MAX_OUTPUT_TOKENS, supportsNetmindJsonResponseFormat, emptyResponseDiagnostics, effectiveMaxTokensFor, completeRawOpenAICompatibleJsonChat, createAiSdkProvider, createFallbackClient, numberLines, renderPrompt, cache, loadPromptTemplate, nullableOptional, AI_VIOLATION_MESSAGE_MAX_LENGTH, aiViolationSchema, aiResponseSchema, stripCodeFence, parseAiResponse, VIETNAMESE_OUTPUT_POLICY_VERSION, VIETNAMESE_OUTPUT_INSTRUCTION, TOKEN_BUDGET_WARN_DEFAULT, CHARS_PER_TOKEN, SAFETY_MARGIN, estimateTokens, formatTokenWarning, braceDelta, chunkSourceForAi, CACHE_NAMESPACE, DEFAULT_PROVIDER_RETRY_MAX_RETRIES, DEFAULT_PROVIDER_RETRY_MAX_DELAY_MS, DEFAULT_ADAPTIVE_RETRY_MAX_RETRIES, DEFAULT_ADAPTIVE_CONTEXT_REDUCTION_FACTOR, DEFAULT_ADAPTIVE_TIMEOUT_MULTIPLIER, DEFAULT_ADAPTIVE_MAX_DELAY_MS, DEFAULT_PROVIDER_TIMEOUT_MS, sleep, parseRetryDelayMs, providerRetryDelayMs, adaptiveFailureKind, compactClusterContext, findingDedupeKey, dedupeFindings, capFindings, createAiExecutor, PATH_FAST_PATHS, SPRING_BOOT_PATTERNS, ANGULAR_PATTERNS, FLUTTER_PATTERNS, ENTRY_HINTS, ALL_PATTERNS, matchesRule, classifyLayer, classifyLayers, PRIMARY_LAYER_CANDIDATES, TEST_AND_GENERATED, LAYER_SUFFIXES, FILE_SUFFIX_RE, ANY_EXT_RE, dropExt, stripPascalSuffix, normalize3, extractDomainTokens, extractDomainTokensBatch, TRIVIAL_TOKENS, sharesDomainToken, TS_IMPORT_RE, JAVA_IMPORT_RE, extractImports, POSIX_SEP_RE, sharedDirDepth, resolveImportTarget, KIND_STRENGTH, upsertEdge, buildEdges, ADVICE_ANNOTATION, isGlobalAdviceFile, findGlobalAdvicePaths, DEFAULT_MAX_CANDIDATES, DEFAULT_MAX_SUPPORT_FILES, DEFAULT_TOKEN_BUDGET, SCORE_DIRECT_NEIGHBOR, SCORE_SECOND_DEGREE, SCORE_SIBLING_STEM, SCORE_ANGULAR_TEMPLATE_SIBLING, SCORE_DOMAIN_TOKEN, PENALTY_TEST_VS_NON_TEST, PENALTY_GENERATED, SCORE_GLOBAL_ADVICE, prefilterCandidates, layerFlowBonus, isTest, isGenerated, scoreFor, tokensOf, trimToBudget, toMember, clusterIdFor, createClusterAssembler, CLUSTER_TREE_BUILDER_VERSION, DEFAULT_MODULE_DEPTH, posixDirname, moduleGroupKey, uniqueSortedPaths, memberFingerprint, featureNodeFor, moduleNodeFor, appNodeFor, countCrossModuleEdges, createClusterTreeBuilder, TRANSACTIONAL, TYPE_DECL3, METHOD_NAME2, MUTATION_CALL, LEADING_ANNOTATION2, SPRING_TX_SUPPORT_IMPORT, PROGRAMMATIC_TYPE, PROGRAMMATIC_CALL, INLINE_TEMPLATE_CALL, CONTROL_FLOW_NAMES, maskNonCode, methodNameFromHeader, methodAt, delegatedTargetAt, collectProgrammaticReceivers, readAttr, skipToDeclaration2, countMutations, lineOf19, configuredReadOnly, extractProgrammaticFromFile, extractFromFile2, extractTransactionBoundaries, renderPrDiffPrompt, nullableOptional2, prDiffResponseSchema, createPrDiffReviewer, renderGroupedRulePrompt, confidenceLabelSchema, severitySchema, groupedResponseSchema, labelToConfidence, createGroupedRuleReviewer, renderPerRulePrompt, createPerRuleReviewer, DEFAULT_MAX_TOKENS, SYSTEM_PROMPT, SCHEMA_PROMPT, clip, buildUserPrompt, extractJsonObject, describeUnusableAnswer, createRuntimeAuthHypothesisResolver, DEFAULT_MAX_TOKENS2, SYSTEM_PROMPT2, SCHEMA_PROMPT2, clip2, buildUserPrompt2, describeUnusableAnswer2, createRuntimeDataSeedResolver, endpointSchema, extractJsonObject2, HTTP_METHODS, PARAMETER_KINDS, ENGLISH_REASON_WORDS, ENGLISH_TECHNICAL_WORDS, VIETNAMESE_DIACRITICS, isLikelyEnglishReason, normalizeTriageReason, parseEndpointHint;
|
|
@@ -31186,10 +31229,10 @@ ${VIETNAMESE_OUTPUT_INSTRUCTION}`
|
|
|
31186
31229
|
];
|
|
31187
31230
|
FILE_SUFFIX_RE = /\.(?:component|service|module|directive|pipe|model|interface|type|spec|test)\.[a-z]+$/i;
|
|
31188
31231
|
ANY_EXT_RE = /\.[a-z]+$/i;
|
|
31189
|
-
dropExt = (
|
|
31190
|
-
const dotted =
|
|
31191
|
-
if (dotted !==
|
|
31192
|
-
return
|
|
31232
|
+
dropExt = (basename12) => {
|
|
31233
|
+
const dotted = basename12.replace(FILE_SUFFIX_RE, "");
|
|
31234
|
+
if (dotted !== basename12) return dotted;
|
|
31235
|
+
return basename12.replace(ANY_EXT_RE, "");
|
|
31193
31236
|
};
|
|
31194
31237
|
stripPascalSuffix = (s) => {
|
|
31195
31238
|
for (const suffix of LAYER_SUFFIXES) {
|
|
@@ -31204,9 +31247,9 @@ ${VIETNAMESE_OUTPUT_INSTRUCTION}`
|
|
|
31204
31247
|
extractDomainTokens = (file) => {
|
|
31205
31248
|
const out = /* @__PURE__ */ new Set();
|
|
31206
31249
|
const segments = file.path.split(/[\\/]/);
|
|
31207
|
-
const
|
|
31208
|
-
if (
|
|
31209
|
-
const stem = dropExt(
|
|
31250
|
+
const basename12 = segments[segments.length - 1] ?? "";
|
|
31251
|
+
if (basename12.length > 0) {
|
|
31252
|
+
const stem = dropExt(basename12);
|
|
31210
31253
|
const token = normalize3(stripPascalSuffix(stem));
|
|
31211
31254
|
if (token.length >= 2) out.add(token);
|
|
31212
31255
|
}
|
|
@@ -31270,9 +31313,9 @@ ${VIETNAMESE_OUTPUT_INSTRUCTION}`
|
|
|
31270
31313
|
if (terminal.length === 0) return null;
|
|
31271
31314
|
const matches = [];
|
|
31272
31315
|
for (const c of candidates) {
|
|
31273
|
-
const
|
|
31274
|
-
const baseNoExt =
|
|
31275
|
-
if (baseNoExt === terminal ||
|
|
31316
|
+
const basename12 = c.path.split(POSIX_SEP_RE).pop() ?? "";
|
|
31317
|
+
const baseNoExt = basename12.replace(/\.[a-z0-9]+$/i, "");
|
|
31318
|
+
if (baseNoExt === terminal || basename12 === terminal) {
|
|
31276
31319
|
if (isRelative) {
|
|
31277
31320
|
const fromDir = fromFile.path.split(POSIX_SEP_RE).slice(0, -1).join("/");
|
|
31278
31321
|
const toDir = c.path.split(POSIX_SEP_RE).slice(0, -1).join("/");
|
|
@@ -36742,6 +36785,87 @@ var init_find_files = __esm({
|
|
|
36742
36785
|
};
|
|
36743
36786
|
}
|
|
36744
36787
|
});
|
|
36788
|
+
|
|
36789
|
+
// src/git-filter.ts
|
|
36790
|
+
var git_filter_exports = {};
|
|
36791
|
+
__export(git_filter_exports, {
|
|
36792
|
+
getGitFilteredPaths: () => getGitFilteredPaths,
|
|
36793
|
+
getRepoRoot: () => getRepoRoot
|
|
36794
|
+
});
|
|
36795
|
+
var execFileAsync, runGit, getRepoRoot, parseNulSeparated, gitArgsForMode, getGitFilteredPaths;
|
|
36796
|
+
var init_git_filter = __esm({
|
|
36797
|
+
"src/git-filter.ts"() {
|
|
36798
|
+
init_dist();
|
|
36799
|
+
execFileAsync = promisify(execFile$1);
|
|
36800
|
+
runGit = async (args, cwd) => {
|
|
36801
|
+
const { stdout } = await execFileAsync("git", [...args], {
|
|
36802
|
+
cwd,
|
|
36803
|
+
encoding: "utf8",
|
|
36804
|
+
// Allow up to 16 MiB of output — should be plenty for a path list.
|
|
36805
|
+
maxBuffer: 16 * 1024 * 1024
|
|
36806
|
+
});
|
|
36807
|
+
return stdout;
|
|
36808
|
+
};
|
|
36809
|
+
getRepoRoot = async (cwd, options = {}) => {
|
|
36810
|
+
try {
|
|
36811
|
+
const cdup = (await runGit(["rev-parse", "--show-cdup"], cwd)).trim();
|
|
36812
|
+
return resolve(cwd, cdup);
|
|
36813
|
+
} catch (error) {
|
|
36814
|
+
if (options.fallbackToCwd) {
|
|
36815
|
+
return resolve(cwd);
|
|
36816
|
+
}
|
|
36817
|
+
throw error;
|
|
36818
|
+
}
|
|
36819
|
+
};
|
|
36820
|
+
parseNulSeparated = (out) => {
|
|
36821
|
+
return out.split("\0").filter((s) => s.length > 0);
|
|
36822
|
+
};
|
|
36823
|
+
gitArgsForMode = (mode, sinceRef) => {
|
|
36824
|
+
switch (mode) {
|
|
36825
|
+
case "staged":
|
|
36826
|
+
return [["diff", "--name-only", "--cached", "-z"]];
|
|
36827
|
+
case "changed":
|
|
36828
|
+
return [
|
|
36829
|
+
["diff", "--name-only", "HEAD", "-z"],
|
|
36830
|
+
["ls-files", "--others", "--exclude-standard", "-z"]
|
|
36831
|
+
];
|
|
36832
|
+
case "since": {
|
|
36833
|
+
if (sinceRef === void 0 || sinceRef.length === 0) {
|
|
36834
|
+
throw new Error("--since requires a non-empty git ref");
|
|
36835
|
+
}
|
|
36836
|
+
return [["diff", "--name-only", sinceRef, "-z"]];
|
|
36837
|
+
}
|
|
36838
|
+
}
|
|
36839
|
+
};
|
|
36840
|
+
getGitFilteredPaths = async (options) => {
|
|
36841
|
+
try {
|
|
36842
|
+
const repoRoot = await getRepoRoot(options.cwd);
|
|
36843
|
+
const argSets = gitArgsForMode(options.mode, options.sinceRef);
|
|
36844
|
+
const collected = /* @__PURE__ */ new Set();
|
|
36845
|
+
for (const args of argSets) {
|
|
36846
|
+
const out = await runGit(args, options.cwd);
|
|
36847
|
+
for (const relPath of parseNulSeparated(out)) {
|
|
36848
|
+
collected.add(resolve(repoRoot, relPath));
|
|
36849
|
+
}
|
|
36850
|
+
}
|
|
36851
|
+
return ok(collected);
|
|
36852
|
+
} catch (e) {
|
|
36853
|
+
const ee = e;
|
|
36854
|
+
const stderr = (ee.stderr ?? "").trim();
|
|
36855
|
+
const msg = stderr.length > 0 ? stderr : ee.message ?? String(e);
|
|
36856
|
+
return err(
|
|
36857
|
+
new IOError(`Git filter failed (--${options.mode}): ${msg}`, {
|
|
36858
|
+
cause: e,
|
|
36859
|
+
context: {
|
|
36860
|
+
mode: options.mode,
|
|
36861
|
+
...options.sinceRef !== void 0 ? { sinceRef: options.sinceRef } : {}
|
|
36862
|
+
}
|
|
36863
|
+
})
|
|
36864
|
+
);
|
|
36865
|
+
}
|
|
36866
|
+
};
|
|
36867
|
+
}
|
|
36868
|
+
});
|
|
36745
36869
|
var severitySchema3, languageSchema, scopeSchema, parserLayerSchema, ruleIdSchema2, confidenceSchema, ruleBaseSchema, staticYamlFixSchema, staticYamlRuleSchema, staticTsRuleSchema, aiConfigSchema, prRoutingSchema, aiRuleSchema, anyRuleSchema, DEFAULT_FINDING_CONFIDENCE, clampConfidence, toFinding, YAML_PATTERN, loadYamlRules, TS_PATTERN, extractRuleExport, loadTsRules, createRuleLoader, ROUTING_PROFILES, DEFAULT_ROUTING_PROFILE, termsFor, inferIntent, routingGroupFor, targetLayersFor, riskWeightFor, relatedContextFor, inferAiRuleRouting, queryCache, predicatesCache, extractPredicates, resolveQuerySource, findCapture, matchSatisfies, getLanguage, getOrCompileQuery, getOrExtractPredicates, nodeRangeToFileRange, pickCaptureNode, executeYamlRule, executeTsRule, DIRECTIVE_RE, parseRuleList, mergeLine, parseSuppressions, normalizeForFingerprint, optionsFingerprint, ruleCacheKey, findingDedupeKey2, findingRootCauseDedupeKey, selectRootCauseRepresentatives, createTaskScheduler, ruleAppliesToFile, requiredLayer, createStaticExecutor, here, compiledRulesDir, sourceRulesDir, builtinRulesDir;
|
|
36746
36870
|
var init_dist8 = __esm({
|
|
36747
36871
|
"../rule-engine/dist/index.js"() {
|
|
@@ -39070,7 +39194,7 @@ var init_sql = __esm({
|
|
|
39070
39194
|
return new SQL([new StringChunk(str)]);
|
|
39071
39195
|
}
|
|
39072
39196
|
sql2.raw = raw;
|
|
39073
|
-
function
|
|
39197
|
+
function join15(chunks, separator) {
|
|
39074
39198
|
const result = [];
|
|
39075
39199
|
for (const [i, chunk] of chunks.entries()) {
|
|
39076
39200
|
if (i > 0 && separator !== void 0) {
|
|
@@ -39080,7 +39204,7 @@ var init_sql = __esm({
|
|
|
39080
39204
|
}
|
|
39081
39205
|
return new SQL(result);
|
|
39082
39206
|
}
|
|
39083
|
-
sql2.join =
|
|
39207
|
+
sql2.join = join15;
|
|
39084
39208
|
function identifier(value) {
|
|
39085
39209
|
return new Name(value);
|
|
39086
39210
|
}
|
|
@@ -41627,7 +41751,7 @@ var init_select2 = __esm({
|
|
|
41627
41751
|
return (table, on) => {
|
|
41628
41752
|
const baseTableName = this.tableName;
|
|
41629
41753
|
const tableName = getTableLikeName(table);
|
|
41630
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
41754
|
+
if (typeof tableName === "string" && this.config.joins?.some((join15) => join15.alias === tableName)) {
|
|
41631
41755
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
41632
41756
|
}
|
|
41633
41757
|
if (!this.isPartialSelect) {
|
|
@@ -42455,7 +42579,7 @@ var init_update = __esm({
|
|
|
42455
42579
|
createJoin(joinType) {
|
|
42456
42580
|
return (table, on) => {
|
|
42457
42581
|
const tableName = getTableLikeName(table);
|
|
42458
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
42582
|
+
if (typeof tableName === "string" && this.config.joins.some((join15) => join15.alias === tableName)) {
|
|
42459
42583
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
42460
42584
|
}
|
|
42461
42585
|
if (typeof on === "function") {
|
|
@@ -47259,6 +47383,7 @@ var init_ai_triage_command = __esm({
|
|
|
47259
47383
|
results.push({
|
|
47260
47384
|
file: toPosix(relative(reportRoot, resolve(source, candidate.file))),
|
|
47261
47385
|
category: candidate.category,
|
|
47386
|
+
status: triageRes.status,
|
|
47262
47387
|
vulnerable: triageRes.vulnerable,
|
|
47263
47388
|
reason: triageRes.reason,
|
|
47264
47389
|
isFalseNegativeCandidate: candidate.isFalseNegativeCandidate,
|
|
@@ -47302,11 +47427,11 @@ var definedBuildValue = (value, fallback) => typeof value === "string" && value.
|
|
|
47302
47427
|
var getCliBuildMetadata = (version2) => ({
|
|
47303
47428
|
version: version2,
|
|
47304
47429
|
gitSha: definedBuildValue(
|
|
47305
|
-
"
|
|
47430
|
+
"30c03b37b3a4" ,
|
|
47306
47431
|
"unknown"
|
|
47307
47432
|
),
|
|
47308
47433
|
buildTimestamp: definedBuildValue(
|
|
47309
|
-
"2026-09-
|
|
47434
|
+
"2026-09-16T04:32:54.599Z" ,
|
|
47310
47435
|
"unknown"
|
|
47311
47436
|
),
|
|
47312
47437
|
configSchemaRange: definedBuildValue(
|
|
@@ -48507,7 +48632,7 @@ var projectListSchema = external_exports.object({
|
|
|
48507
48632
|
total: external_exports.number().int().nonnegative(),
|
|
48508
48633
|
limit: external_exports.number().int().positive(),
|
|
48509
48634
|
offset: external_exports.number().int().nonnegative()
|
|
48510
|
-
}).
|
|
48635
|
+
}).passthrough();
|
|
48511
48636
|
var createProjectRequestSchema = external_exports.object({
|
|
48512
48637
|
id: projectIdSchema,
|
|
48513
48638
|
name: external_exports.string().trim().min(1).max(255),
|
|
@@ -48553,7 +48678,7 @@ var dashboardRunListSchema = external_exports.object({
|
|
|
48553
48678
|
total: external_exports.number().int().nonnegative(),
|
|
48554
48679
|
limit: external_exports.number().int().positive(),
|
|
48555
48680
|
offset: external_exports.number().int().nonnegative()
|
|
48556
|
-
}).
|
|
48681
|
+
}).passthrough();
|
|
48557
48682
|
var dashboardRunDetailSchema = external_exports.object({ run: external_exports.unknown() }).strict();
|
|
48558
48683
|
var repositoryRuleExportSchema = external_exports.object({
|
|
48559
48684
|
schemaVersion: external_exports.literal(1),
|
|
@@ -48662,6 +48787,7 @@ var createCliApiClient = (options) => {
|
|
|
48662
48787
|
const controller = new AbortController();
|
|
48663
48788
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
48664
48789
|
const requestId = (options.requestId ?? defaultRequestId)();
|
|
48790
|
+
let payload;
|
|
48665
48791
|
try {
|
|
48666
48792
|
const response = await requestWithAuthorization(
|
|
48667
48793
|
path,
|
|
@@ -48671,7 +48797,7 @@ var createCliApiClient = (options) => {
|
|
|
48671
48797
|
requestId
|
|
48672
48798
|
);
|
|
48673
48799
|
if (!response.ok) throw await asError(response, requestId);
|
|
48674
|
-
|
|
48800
|
+
payload = await response.json();
|
|
48675
48801
|
} catch (error) {
|
|
48676
48802
|
if (error instanceof CliApiClientRequestError) throw error;
|
|
48677
48803
|
const message = error instanceof Error && error.name === "AbortError" ? "Request timed out." : "Network request failed.";
|
|
@@ -48684,6 +48810,18 @@ var createCliApiClient = (options) => {
|
|
|
48684
48810
|
} finally {
|
|
48685
48811
|
clearTimeout(timer);
|
|
48686
48812
|
}
|
|
48813
|
+
try {
|
|
48814
|
+
return parse2(payload);
|
|
48815
|
+
} catch (error) {
|
|
48816
|
+
if (error instanceof CliApiClientRequestError) throw error;
|
|
48817
|
+
const message = error instanceof Error ? `Invalid response format: ${error.message}` : "Invalid response format.";
|
|
48818
|
+
throw new CliApiClientRequestError({
|
|
48819
|
+
status: 0,
|
|
48820
|
+
requestId,
|
|
48821
|
+
message,
|
|
48822
|
+
retryable: false
|
|
48823
|
+
});
|
|
48824
|
+
}
|
|
48687
48825
|
};
|
|
48688
48826
|
const requestText = async (path, init) => {
|
|
48689
48827
|
const controller = new AbortController();
|
|
@@ -48925,11 +49063,29 @@ var FileWorkspaceLinkStore = class {
|
|
|
48925
49063
|
constructor(root = process.cwd()) {
|
|
48926
49064
|
this.#filePath = join(resolve(root), ".code-sentinel", stateFileName);
|
|
48927
49065
|
}
|
|
49066
|
+
get filePath() {
|
|
49067
|
+
return this.#filePath;
|
|
49068
|
+
}
|
|
48928
49069
|
async read() {
|
|
48929
49070
|
try {
|
|
48930
|
-
|
|
48931
|
-
|
|
48932
|
-
|
|
49071
|
+
const content = await readFile(this.#filePath, "utf8");
|
|
49072
|
+
let parsedJson;
|
|
49073
|
+
try {
|
|
49074
|
+
parsedJson = JSON.parse(content);
|
|
49075
|
+
} catch (err2) {
|
|
49076
|
+
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
49077
|
+
throw new Error(`Workspace link state at ${this.#filePath} is invalid JSON: ${msg}`);
|
|
49078
|
+
}
|
|
49079
|
+
const parsed = parseLink(parsedJson);
|
|
49080
|
+
if (!parsed) {
|
|
49081
|
+
throw new Error(`Workspace link state at ${this.#filePath} is invalid or unsafe.`);
|
|
49082
|
+
}
|
|
49083
|
+
return parsed;
|
|
49084
|
+
} catch (error) {
|
|
49085
|
+
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
49086
|
+
return null;
|
|
49087
|
+
}
|
|
49088
|
+
throw error;
|
|
48933
49089
|
}
|
|
48934
49090
|
}
|
|
48935
49091
|
async write(link) {
|
|
@@ -48949,6 +49105,33 @@ var FileWorkspaceLinkStore = class {
|
|
|
48949
49105
|
await rm4(this.#filePath, { force: true });
|
|
48950
49106
|
}
|
|
48951
49107
|
};
|
|
49108
|
+
var findWorkspaceLink = async (startDir) => {
|
|
49109
|
+
const { getRepoRoot: getRepoRoot2 } = await Promise.resolve().then(() => (init_git_filter(), git_filter_exports));
|
|
49110
|
+
let boundary = startDir;
|
|
49111
|
+
try {
|
|
49112
|
+
boundary = await getRepoRoot2(startDir, { fallbackToCwd: true });
|
|
49113
|
+
} catch {
|
|
49114
|
+
}
|
|
49115
|
+
let currentDir = resolve(startDir);
|
|
49116
|
+
const boundaryDir = resolve(boundary);
|
|
49117
|
+
while (true) {
|
|
49118
|
+
const store = new FileWorkspaceLinkStore(currentDir);
|
|
49119
|
+
const link = await store.read();
|
|
49120
|
+
if (link) {
|
|
49121
|
+
return {
|
|
49122
|
+
link,
|
|
49123
|
+
root: currentDir,
|
|
49124
|
+
filePath: store.filePath,
|
|
49125
|
+
store
|
|
49126
|
+
};
|
|
49127
|
+
}
|
|
49128
|
+
if (currentDir === boundaryDir || currentDir === dirname(currentDir)) {
|
|
49129
|
+
break;
|
|
49130
|
+
}
|
|
49131
|
+
currentDir = dirname(currentDir);
|
|
49132
|
+
}
|
|
49133
|
+
return null;
|
|
49134
|
+
};
|
|
48952
49135
|
|
|
48953
49136
|
// src/commands/pentest-verify-io.ts
|
|
48954
49137
|
init_dist5();
|
|
@@ -49636,8 +49819,11 @@ var runAssess = async (options, deps = {}) => {
|
|
|
49636
49819
|
const match = triageResults.find(
|
|
49637
49820
|
(r) => r.file === finding.file && r.category === category && !r.isFalseNegativeCandidate
|
|
49638
49821
|
);
|
|
49639
|
-
if (match
|
|
49640
|
-
|
|
49822
|
+
if (match) {
|
|
49823
|
+
const isExplicitlySafe = match.status === "safe" || match.status === void 0 && !match.vulnerable && typeof match.reason === "string" && !match.reason.startsWith("L\u1ED7i") && !match.reason.startsWith("LLM");
|
|
49824
|
+
if (isExplicitlySafe) {
|
|
49825
|
+
return false;
|
|
49826
|
+
}
|
|
49641
49827
|
}
|
|
49642
49828
|
return true;
|
|
49643
49829
|
});
|
|
@@ -49986,7 +50172,8 @@ var runAssess = async (options, deps = {}) => {
|
|
|
49986
50172
|
}
|
|
49987
50173
|
}
|
|
49988
50174
|
if (options.push === true) {
|
|
49989
|
-
const
|
|
50175
|
+
const resolvedLink = await findWorkspaceLink(target);
|
|
50176
|
+
const link = resolvedLink?.link ?? null;
|
|
49990
50177
|
if (!link) {
|
|
49991
50178
|
console.error(
|
|
49992
50179
|
red(
|
|
@@ -50730,11 +50917,11 @@ ${subject}`));
|
|
|
50730
50917
|
};
|
|
50731
50918
|
|
|
50732
50919
|
// src/commands/auth.command.ts
|
|
50733
|
-
var
|
|
50920
|
+
var execFile3 = promisify(execFile$1);
|
|
50734
50921
|
var openBrowser = async (url) => {
|
|
50735
|
-
if (process.platform === "darwin") await
|
|
50736
|
-
else if (process.platform === "win32") await
|
|
50737
|
-
else await
|
|
50922
|
+
if (process.platform === "darwin") await execFile3("open", [url]);
|
|
50923
|
+
else if (process.platform === "win32") await execFile3("cmd", ["/c", "start", "", url]);
|
|
50924
|
+
else await execFile3("xdg-open", [url]);
|
|
50738
50925
|
};
|
|
50739
50926
|
var credentialStore = () => createPlatformCredentialStore();
|
|
50740
50927
|
var sleep2 = (milliseconds) => new Promise((resolve55) => setTimeout(resolve55, milliseconds));
|
|
@@ -50895,7 +51082,8 @@ var authenticatedClient = async (server, store) => {
|
|
|
50895
51082
|
};
|
|
50896
51083
|
var projectIdFor = async (path, projectId) => {
|
|
50897
51084
|
if (projectId) return projectId;
|
|
50898
|
-
const
|
|
51085
|
+
const resolvedLink = await findWorkspaceLink(path ?? process.cwd());
|
|
51086
|
+
const link = resolvedLink?.link ?? null;
|
|
50899
51087
|
if (!link)
|
|
50900
51088
|
throw new Error("This workspace is not linked. Run `cs project` first or pass --project-id.");
|
|
50901
51089
|
return link.projectId;
|
|
@@ -51372,76 +51560,8 @@ var createFindingBatchPublisher = (options) => {
|
|
|
51372
51560
|
};
|
|
51373
51561
|
};
|
|
51374
51562
|
|
|
51375
|
-
// src/
|
|
51376
|
-
|
|
51377
|
-
var execFileAsync = promisify(execFile$1);
|
|
51378
|
-
var runGit = async (args, cwd) => {
|
|
51379
|
-
const { stdout } = await execFileAsync("git", [...args], {
|
|
51380
|
-
cwd,
|
|
51381
|
-
encoding: "utf8",
|
|
51382
|
-
// Allow up to 16 MiB of output — should be plenty for a path list.
|
|
51383
|
-
maxBuffer: 16 * 1024 * 1024
|
|
51384
|
-
});
|
|
51385
|
-
return stdout;
|
|
51386
|
-
};
|
|
51387
|
-
var getRepoRoot = async (cwd, options = {}) => {
|
|
51388
|
-
try {
|
|
51389
|
-
const cdup = (await runGit(["rev-parse", "--show-cdup"], cwd)).trim();
|
|
51390
|
-
return resolve(cwd, cdup);
|
|
51391
|
-
} catch (error) {
|
|
51392
|
-
if (options.fallbackToCwd) {
|
|
51393
|
-
return resolve(cwd);
|
|
51394
|
-
}
|
|
51395
|
-
throw error;
|
|
51396
|
-
}
|
|
51397
|
-
};
|
|
51398
|
-
var parseNulSeparated = (out) => {
|
|
51399
|
-
return out.split("\0").filter((s) => s.length > 0);
|
|
51400
|
-
};
|
|
51401
|
-
var gitArgsForMode = (mode, sinceRef) => {
|
|
51402
|
-
switch (mode) {
|
|
51403
|
-
case "staged":
|
|
51404
|
-
return [["diff", "--name-only", "--cached", "-z"]];
|
|
51405
|
-
case "changed":
|
|
51406
|
-
return [
|
|
51407
|
-
["diff", "--name-only", "HEAD", "-z"],
|
|
51408
|
-
["ls-files", "--others", "--exclude-standard", "-z"]
|
|
51409
|
-
];
|
|
51410
|
-
case "since": {
|
|
51411
|
-
if (sinceRef === void 0 || sinceRef.length === 0) {
|
|
51412
|
-
throw new Error("--since requires a non-empty git ref");
|
|
51413
|
-
}
|
|
51414
|
-
return [["diff", "--name-only", sinceRef, "-z"]];
|
|
51415
|
-
}
|
|
51416
|
-
}
|
|
51417
|
-
};
|
|
51418
|
-
var getGitFilteredPaths = async (options) => {
|
|
51419
|
-
try {
|
|
51420
|
-
const repoRoot = await getRepoRoot(options.cwd);
|
|
51421
|
-
const argSets = gitArgsForMode(options.mode, options.sinceRef);
|
|
51422
|
-
const collected = /* @__PURE__ */ new Set();
|
|
51423
|
-
for (const args of argSets) {
|
|
51424
|
-
const out = await runGit(args, options.cwd);
|
|
51425
|
-
for (const relPath of parseNulSeparated(out)) {
|
|
51426
|
-
collected.add(resolve(repoRoot, relPath));
|
|
51427
|
-
}
|
|
51428
|
-
}
|
|
51429
|
-
return ok(collected);
|
|
51430
|
-
} catch (e) {
|
|
51431
|
-
const ee = e;
|
|
51432
|
-
const stderr = (ee.stderr ?? "").trim();
|
|
51433
|
-
const msg = stderr.length > 0 ? stderr : ee.message ?? String(e);
|
|
51434
|
-
return err(
|
|
51435
|
-
new IOError(`Git filter failed (--${options.mode}): ${msg}`, {
|
|
51436
|
-
cause: e,
|
|
51437
|
-
context: {
|
|
51438
|
-
mode: options.mode,
|
|
51439
|
-
...options.sinceRef !== void 0 ? { sinceRef: options.sinceRef } : {}
|
|
51440
|
-
}
|
|
51441
|
-
})
|
|
51442
|
-
);
|
|
51443
|
-
}
|
|
51444
|
-
};
|
|
51563
|
+
// src/commands/review.command.ts
|
|
51564
|
+
init_git_filter();
|
|
51445
51565
|
|
|
51446
51566
|
// src/match-glob.ts
|
|
51447
51567
|
var REGEX_META = /[.+^${}()|[\]\\]/;
|
|
@@ -52088,7 +52208,11 @@ var runPush = async (options = {}, deps = {}) => {
|
|
|
52088
52208
|
return EXIT.USAGE;
|
|
52089
52209
|
}
|
|
52090
52210
|
const config = loaded.value.config;
|
|
52091
|
-
const
|
|
52211
|
+
const resolvedLinkStore = await findWorkspaceLink(target);
|
|
52212
|
+
const link = resolvedLinkStore?.link ?? null;
|
|
52213
|
+
if (resolvedLinkStore && !options.server) {
|
|
52214
|
+
console.log(dim(`S\u1EED d\u1EE5ng c\u1EA5u h\xECnh d\u1EF1 \xE1n t\u1EEB: ${resolvedLinkStore.filePath}`));
|
|
52215
|
+
}
|
|
52092
52216
|
const serverUrl = options.server ?? link?.serverUrl ?? config.dashboard.serverUrl ?? process.env.CODE_SENTINEL_DASHBOARD_URL ?? getDefaultDashboardServerUrl();
|
|
52093
52217
|
if (serverUrl === void 0 || serverUrl.length === 0) {
|
|
52094
52218
|
console.error(
|
|
@@ -53125,6 +53249,7 @@ init_dist7();
|
|
|
53125
53249
|
init_dist8();
|
|
53126
53250
|
init_composition();
|
|
53127
53251
|
init_find_files();
|
|
53252
|
+
init_git_filter();
|
|
53128
53253
|
|
|
53129
53254
|
// src/rule-overrides.ts
|
|
53130
53255
|
var buildRuleOverrides = (rulesCfg) => {
|
|
@@ -54863,10 +54988,10 @@ var ReaddirpStream = class extends Readable {
|
|
|
54863
54988
|
}
|
|
54864
54989
|
async _formatEntry(dirent, path) {
|
|
54865
54990
|
let entry;
|
|
54866
|
-
const
|
|
54991
|
+
const basename12 = this._isDirent ? dirent.name : dirent;
|
|
54867
54992
|
try {
|
|
54868
|
-
const fullPath = resolve(join(path,
|
|
54869
|
-
entry = { path: relative(this._root, fullPath), fullPath, basename:
|
|
54993
|
+
const fullPath = resolve(join(path, basename12));
|
|
54994
|
+
entry = { path: relative(this._root, fullPath), fullPath, basename: basename12 };
|
|
54870
54995
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
54871
54996
|
} catch (err2) {
|
|
54872
54997
|
this._onError(err2);
|
|
@@ -55401,9 +55526,9 @@ var NodeFsHandler = class {
|
|
|
55401
55526
|
_watchWithNodeFs(path, listener) {
|
|
55402
55527
|
const opts = this.fsw.options;
|
|
55403
55528
|
const directory = sp2.dirname(path);
|
|
55404
|
-
const
|
|
55529
|
+
const basename12 = sp2.basename(path);
|
|
55405
55530
|
const parent = this.fsw._getWatchedDir(directory);
|
|
55406
|
-
parent.add(
|
|
55531
|
+
parent.add(basename12);
|
|
55407
55532
|
const absolutePath = sp2.resolve(path);
|
|
55408
55533
|
const options = {
|
|
55409
55534
|
persistent: opts.persistent
|
|
@@ -55413,7 +55538,7 @@ var NodeFsHandler = class {
|
|
|
55413
55538
|
let closer;
|
|
55414
55539
|
if (opts.usePolling) {
|
|
55415
55540
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
55416
|
-
options.interval = enableBin && isBinaryPath(
|
|
55541
|
+
options.interval = enableBin && isBinaryPath(basename12) ? opts.binaryInterval : opts.interval;
|
|
55417
55542
|
closer = setFsWatchFileListener(path, absolutePath, options, {
|
|
55418
55543
|
listener,
|
|
55419
55544
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -55436,10 +55561,10 @@ var NodeFsHandler = class {
|
|
|
55436
55561
|
return;
|
|
55437
55562
|
}
|
|
55438
55563
|
const dirname27 = sp2.dirname(file);
|
|
55439
|
-
const
|
|
55564
|
+
const basename12 = sp2.basename(file);
|
|
55440
55565
|
const parent = this.fsw._getWatchedDir(dirname27);
|
|
55441
55566
|
let prevStats = stats;
|
|
55442
|
-
if (parent.has(
|
|
55567
|
+
if (parent.has(basename12))
|
|
55443
55568
|
return;
|
|
55444
55569
|
const listener = async (path, newStats) => {
|
|
55445
55570
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
@@ -55464,9 +55589,9 @@ var NodeFsHandler = class {
|
|
|
55464
55589
|
prevStats = newStats2;
|
|
55465
55590
|
}
|
|
55466
55591
|
} catch (error) {
|
|
55467
|
-
this.fsw._remove(dirname27,
|
|
55592
|
+
this.fsw._remove(dirname27, basename12);
|
|
55468
55593
|
}
|
|
55469
|
-
} else if (parent.has(
|
|
55594
|
+
} else if (parent.has(basename12)) {
|
|
55470
55595
|
const at = newStats.atimeMs;
|
|
55471
55596
|
const mt = newStats.mtimeMs;
|
|
55472
55597
|
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
|
@@ -56592,7 +56717,8 @@ var runConfigEffective = async (options = {}) => {
|
|
|
56592
56717
|
}
|
|
56593
56718
|
if (options.online) {
|
|
56594
56719
|
const root = resolve(options.path ?? process.cwd());
|
|
56595
|
-
const
|
|
56720
|
+
const resolvedLink = await findWorkspaceLink(root);
|
|
56721
|
+
const link = resolvedLink?.link ?? null;
|
|
56596
56722
|
if (!link) {
|
|
56597
56723
|
writeError("Workspace is not linked. Run `cs project link` before online config resolution.");
|
|
56598
56724
|
return EXIT.USAGE;
|
|
@@ -57552,7 +57678,11 @@ var runReview = async (options = {}) => {
|
|
|
57552
57678
|
return EXIT.RUNTIME;
|
|
57553
57679
|
}
|
|
57554
57680
|
try {
|
|
57555
|
-
const
|
|
57681
|
+
const resolvedLink = await findWorkspaceLink(target);
|
|
57682
|
+
const link = resolvedLink?.link ?? null;
|
|
57683
|
+
if (resolvedLink && options.push) {
|
|
57684
|
+
console.log(dim(`S\u1EED d\u1EE5ng c\u1EA5u h\xECnh d\u1EF1 \xE1n t\u1EEB: ${resolvedLink.filePath}`));
|
|
57685
|
+
}
|
|
57556
57686
|
const credential = link ? await createPlatformCredentialStore().read(link.serverUrl) : null;
|
|
57557
57687
|
if (link && credential) {
|
|
57558
57688
|
await new FileProtectedRetryStore(target, createPlatformRetryKeyProvider()).enqueue({
|
|
@@ -60278,7 +60408,10 @@ init_schema();
|
|
|
60278
60408
|
init_exit_codes();
|
|
60279
60409
|
var execFile5 = promisify(execFile$1);
|
|
60280
60410
|
var defaultDependencies = (root) => ({
|
|
60281
|
-
readLink: () =>
|
|
60411
|
+
readLink: async () => {
|
|
60412
|
+
const resolvedLink = await findWorkspaceLink(root);
|
|
60413
|
+
return resolvedLink?.link ?? null;
|
|
60414
|
+
},
|
|
60282
60415
|
readOriginRemote: async () => {
|
|
60283
60416
|
try {
|
|
60284
60417
|
const { stdout } = await execFile5("git", ["remote", "get-url", "origin"], {
|
|
@@ -60503,7 +60636,8 @@ var runProjectLink = async (options) => {
|
|
|
60503
60636
|
var linkedProjectId = async (options) => {
|
|
60504
60637
|
const root = resolve(options.path ?? process.cwd());
|
|
60505
60638
|
if (options.projectId) return { root, projectId: options.projectId };
|
|
60506
|
-
const
|
|
60639
|
+
const resolvedLink = await findWorkspaceLink(root);
|
|
60640
|
+
const link = resolvedLink?.link ?? null;
|
|
60507
60641
|
if (!link)
|
|
60508
60642
|
throw new Error("This workspace is not linked. Run `cs project` first or pass --project-id.");
|
|
60509
60643
|
return { root, projectId: link.projectId };
|
|
@@ -61133,932 +61267,246 @@ var runQuickstart = async (options = {}) => {
|
|
|
61133
61267
|
|
|
61134
61268
|
// src/commands/package.command.ts
|
|
61135
61269
|
init_dist2();
|
|
61136
|
-
init_load();
|
|
61137
|
-
init_ai_triage_command();
|
|
61138
|
-
|
|
61139
|
-
// src/commands/runtime-auth-seed.command.ts
|
|
61140
|
-
init_dist6();
|
|
61141
|
-
init_dist2();
|
|
61142
61270
|
init_dist5();
|
|
61143
|
-
init_dist();
|
|
61144
|
-
init_composition();
|
|
61145
61271
|
init_load();
|
|
61146
|
-
|
|
61147
|
-
|
|
61148
|
-
var
|
|
61149
|
-
|
|
61150
|
-
|
|
61151
|
-
|
|
61152
|
-
|
|
61153
|
-
|
|
61154
|
-
|
|
61155
|
-
|
|
61156
|
-
|
|
61157
|
-
|
|
61158
|
-
|
|
61159
|
-
|
|
61160
|
-
var AUTH_SOURCE_RE = /(Filter|Interceptor|Security(Config|Configuration)|Authentication|Authoriz|TokenService|TokenProvider|JwtUtil|UserContext|SessionRegistry)/;
|
|
61161
|
-
var AUTH_CLASS_RE = /((Filter|Interceptor|Aspect)$)|^(UserContext|TokenService|TokenProvider|RedisAbstract|RedisKey|SecurityConfig)/;
|
|
61162
|
-
var MAX_CLASS_NAMES = 120;
|
|
61163
|
-
var MAX_SOURCE_EXCERPTS = 12;
|
|
61164
|
-
var simpleClassName2 = (entry) => (entry.split("/").pop() ?? entry).replace(/\.class$/, "");
|
|
61165
|
-
var DEFAULT_REDIS_HOST = "127.0.0.1";
|
|
61166
|
-
var DEFAULT_REDIS_PORT = 6379;
|
|
61167
|
-
var buildEvidence = (configs, bundled, sources, classNames, classConstants = []) => {
|
|
61168
|
-
const relevant = classNames.filter((n) => AUTH_CLASS_RE.test(simpleClassName2(n))).slice(0, MAX_CLASS_NAMES);
|
|
61169
|
-
const out = [];
|
|
61170
|
-
if (relevant.length > 0) {
|
|
61171
|
-
out.push({
|
|
61172
|
-
path: "<declared jars> \u2014 auth-relevant class inventory",
|
|
61173
|
-
content: [
|
|
61174
|
-
"These classes ship inside the jars this project declares. The authentication gate may be",
|
|
61175
|
-
"implemented here rather than in the source tree; name the scheme from these if so.",
|
|
61176
|
-
"",
|
|
61177
|
-
...relevant
|
|
61178
|
-
].join(String.fromCharCode(10))
|
|
61179
|
-
});
|
|
61180
|
-
}
|
|
61181
|
-
for (const c of classConstants) {
|
|
61182
|
-
if (c.constants.length === 0) continue;
|
|
61183
|
-
out.push({
|
|
61184
|
-
path: `${c.entry} \u2014 string constants`,
|
|
61185
|
-
content: c.constants.join(String.fromCharCode(10))
|
|
61186
|
-
});
|
|
61272
|
+
init_git_filter();
|
|
61273
|
+
var HYPOTHESIS_ENTRY = ".code-sentinel/auth-hypothesis.json";
|
|
61274
|
+
var DATA_SEED_HYPOTHESIS_ENTRY = ".code-sentinel/data-seed-hypothesis.json";
|
|
61275
|
+
var AI_TRIAGE_ENTRY = ".code-sentinel/ai-triage-assessment.json";
|
|
61276
|
+
var formatBytes = (n) => n > 1024 * 1024 ? `${(n / (1024 * 1024)).toFixed(1)} MB` : `${(n / 1024).toFixed(0)} KB`;
|
|
61277
|
+
var runPackageCommand = async (options) => {
|
|
61278
|
+
const targetDirAbs = resolve(
|
|
61279
|
+
options.targetDir && options.targetDir.trim() !== "" ? options.targetDir : options.source && options.source.trim() !== "" ? options.source : "."
|
|
61280
|
+
);
|
|
61281
|
+
const repoRoot = await getRepoRoot(targetDirAbs, { fallbackToCwd: true });
|
|
61282
|
+
let modulePath = options.module;
|
|
61283
|
+
if (modulePath === void 0 || modulePath.trim() === "") {
|
|
61284
|
+
modulePath = relative(repoRoot, targetDirAbs);
|
|
61285
|
+
if (modulePath === "") modulePath = ".";
|
|
61187
61286
|
}
|
|
61188
|
-
|
|
61189
|
-
|
|
61190
|
-
|
|
61191
|
-
|
|
61192
|
-
console.error(
|
|
61193
|
-
"[auth-seed] --emit-hypothesis v\xE0 --hypothesis lo\u1EA1i tr\u1EEB nhau: m\u1ED9t b\xEAn GI\u1EA2I (ch\u1EA1y ngo\xE0i namespace c\xF4 l\u1EADp), m\u1ED9t b\xEAn TI\xCAU TH\u1EE4 (ch\u1EA1y trong pod)."
|
|
61287
|
+
const effectiveTarget = resolve(repoRoot, modulePath);
|
|
61288
|
+
if (!options.push && (options.resolveAuth || options.resolveDataSeed || options.refreshHypothesis)) {
|
|
61289
|
+
process.stderr.write(
|
|
61290
|
+
"cs package: C\xE1c c\u1EDD AI c\u1EE5c b\u1ED9 (--resolve-auth, --resolve-data-seed, --refresh-hypothesis) \u0111\xE3 b\u1ECB lo\u1EA1i b\u1ECF. AI hi\u1EC7n \u0111\u01B0\u1EE3c th\u1EF1c thi t\u1EADp trung tr\xEAn m\xE1y ch\u1EE7 (Server-Centric). H\xE3y d\xF9ng l\u1EC7nh `cs pentest` \u0111\u1EC3 t\u1EF1 \u0111\u1ED9ng \u0111\xF3ng g\xF3i v\xE0 ch\u1EA1y AI tr\xEAn m\xE1y ch\u1EE7.\n"
|
|
61194
61291
|
);
|
|
61195
|
-
return EXIT.USAGE;
|
|
61196
61292
|
}
|
|
61197
|
-
|
|
61198
|
-
|
|
61199
|
-
|
|
61200
|
-
|
|
61201
|
-
|
|
61202
|
-
|
|
61203
|
-
|
|
61204
|
-
|
|
61205
|
-
|
|
61293
|
+
let serverUrl = getDefaultDashboardServerUrl();
|
|
61294
|
+
let token = process.env.CODE_SENTINEL_DASHBOARD_TOKEN;
|
|
61295
|
+
let link = null;
|
|
61296
|
+
let resolvedLinkStore = null;
|
|
61297
|
+
if (options.push) {
|
|
61298
|
+
const loaded = await loadConfig(
|
|
61299
|
+
options.config === void 0 ? { cwd: repoRoot } : { cwd: repoRoot, configPath: options.config }
|
|
61300
|
+
);
|
|
61301
|
+
const config = loaded.ok ? loaded.value.config : void 0;
|
|
61302
|
+
resolvedLinkStore = await findWorkspaceLink(effectiveTarget);
|
|
61303
|
+
link = resolvedLinkStore?.link ?? null;
|
|
61304
|
+
if (!link) {
|
|
61305
|
+
console.error(
|
|
61306
|
+
red(
|
|
61307
|
+
"\nD\u1EF1 \xE1n ch\u01B0a \u0111\u01B0\u1EE3c li\xEAn k\u1EBFt (link) v\u1EDBi m\xE1y ch\u1EE7! H\xE3y ch\u1EA1y `cs project link` tr\u01B0\u1EDBc khi ch\u1EA1y `cs pentest`."
|
|
61308
|
+
)
|
|
61309
|
+
);
|
|
61310
|
+
return 2;
|
|
61311
|
+
}
|
|
61312
|
+
serverUrl = link.serverUrl ?? config?.dashboard?.serverUrl ?? getDefaultDashboardServerUrl();
|
|
61313
|
+
if (!token) {
|
|
61314
|
+
token = config?.dashboard?.token;
|
|
61315
|
+
}
|
|
61316
|
+
if (!token) {
|
|
61317
|
+
try {
|
|
61318
|
+
const store = createPlatformCredentialStore();
|
|
61319
|
+
const credential = await getAuthenticatedCredential({ server: serverUrl, store });
|
|
61320
|
+
token = credential.accessToken;
|
|
61321
|
+
} catch (e) {
|
|
61322
|
+
console.error(
|
|
61323
|
+
red(
|
|
61324
|
+
`
|
|
61325
|
+
Kh\xF4ng th\u1EC3 l\u1EA5y x\xE1c th\u1EF1c Dashboard: ${e instanceof Error ? e.message : String(e)}
|
|
61326
|
+
H\xE3y ch\u1EA1y \`cs auth login\`.`
|
|
61327
|
+
)
|
|
61328
|
+
);
|
|
61329
|
+
return 2;
|
|
61330
|
+
}
|
|
61331
|
+
}
|
|
61332
|
+
try {
|
|
61333
|
+
const configUrl = `${serverUrl.replace(/\/+$/, "")}/api/projects/${encodeURIComponent(link.projectId)}/review-config`;
|
|
61334
|
+
const configRes = await fetch(configUrl, {
|
|
61335
|
+
headers: { authorization: `Bearer ${token}` }
|
|
61336
|
+
});
|
|
61337
|
+
if (configRes.ok) {
|
|
61338
|
+
const payload = await configRes.json();
|
|
61339
|
+
const remoteConfig = payload.config ?? payload;
|
|
61340
|
+
const ai = remoteConfig?.ai;
|
|
61341
|
+
const provider = ai?.provider ?? remoteConfig?.aiProvider ?? "viettel-netmind";
|
|
61342
|
+
if (provider && provider !== "none" && provider !== "ollama") {
|
|
61343
|
+
const STORED_SECRET_PLACEHOLDER = "${CODE_SENTINEL_STORED_SECRET}";
|
|
61344
|
+
const pKey = provider === "viettel-netmind" ? "viettelNetmind" : provider === "openai-compatible" ? "openaiCompatible" : provider === "opencode-go" ? "opencodeGo" : provider;
|
|
61345
|
+
const providerConf = typeof ai?.[pKey] === "object" && ai?.[pKey] !== null ? ai[pKey] : {};
|
|
61346
|
+
const rawProviderApiKey = typeof providerConf.apiKey === "string" ? providerConf.apiKey.trim() : typeof ai?.apiKey === "string" ? ai.apiKey.trim() : "";
|
|
61347
|
+
const hasServerSecret = rawProviderApiKey === STORED_SECRET_PLACEHOLDER || rawProviderApiKey === "<configured server secret>" || rawProviderApiKey.startsWith("csenc:v1:");
|
|
61348
|
+
const hasExplicitKey = rawProviderApiKey.length > 0 && !hasServerSecret && !/^\$\{[A-Z0-9_]+\}$/.test(rawProviderApiKey);
|
|
61349
|
+
if (!hasServerSecret && !hasExplicitKey) {
|
|
61350
|
+
const drawerUrl = `${serverUrl.replace(/\/+$/, "")}/runs?project=${encodeURIComponent(link.projectId)}&drawer=pentest`;
|
|
61351
|
+
console.error(
|
|
61352
|
+
red("\n\u274C [Server] D\u1EF1 \xE1n ch\u01B0a \u0111\u01B0\u1EE3c c\u1EA5u h\xECnh Project AI Key tr\xEAn Web Dashboard.")
|
|
61353
|
+
);
|
|
61354
|
+
console.error(
|
|
61355
|
+
red(
|
|
61356
|
+
`\u{1F449} Vui l\xF2ng m\u1EDF drawer Pentest tr\xEAn Web Dashboard \u0111\u1EC3 nh\u1EADp API Key:
|
|
61357
|
+
${drawerUrl}
|
|
61358
|
+
`
|
|
61359
|
+
)
|
|
61360
|
+
);
|
|
61361
|
+
console.error(
|
|
61362
|
+
red(
|
|
61363
|
+
`H\u01B0\u1EDBng d\u1EABn thao t\xE1c:
|
|
61364
|
+
1. M\u1EDF link tr\xEAn (ho\u1EB7c v\xE0o D\u1EF1 \xE1n -> b\u1EA5m n\xFAt "Pentest" \u0111\u1EC3 m\u1EDF drawer "Ki\u1EC3m th\u1EED trong m\xF4i tr\u01B0\u1EDDng c\xF4 l\u1EADp").
|
|
61365
|
+
2. T\u1EA1i m\u1EE5c "Project AI Key (${provider})", nh\u1EADp API Key v\xE0 nh\u1EA5n "L\u01B0u key cho d\u1EF1 \xE1n".
|
|
61366
|
+
3. Sau khi l\u01B0u key, ch\u1EA1y l\u1EA1i l\u1EC7nh \`cs pentest\`.
|
|
61367
|
+
|
|
61368
|
+
Ghi ch\xFA: L\u1EC7nh \`cs pentest\` s\u1EED d\u1EE5ng Project AI Key tr\xEAn m\xE1y ch\u1EE7 \u0111\u1EC3 t\u1EF1 \u0111\u1ED9ng th\u1EF1c hi\u1EC7n:
|
|
61369
|
+
- Ph\xE2n t\xEDch & gi\u1EA3i quy\u1EBFt c\u01A1 ch\u1EBF x\xE1c th\u1EF1c (Auth Hypothesis)
|
|
61370
|
+
- Two-Way AI Triage (lo\u1EA1i b\u1ECF False Positive, t\xECm False Negative)
|
|
61371
|
+
- T\u1EA1o d\u1EEF li\u1EC7u m\u1ED3i (Data Seed Hypothesis)
|
|
61372
|
+
`
|
|
61373
|
+
)
|
|
61374
|
+
);
|
|
61375
|
+
return 2;
|
|
61376
|
+
}
|
|
61377
|
+
}
|
|
61378
|
+
}
|
|
61379
|
+
} catch {
|
|
61380
|
+
}
|
|
61206
61381
|
}
|
|
61207
|
-
const
|
|
61208
|
-
|
|
61209
|
-
|
|
61210
|
-
|
|
61211
|
-
|
|
61212
|
-
const pomsResult = await findFiles({
|
|
61213
|
-
projectRoot: source,
|
|
61214
|
-
include: POM_GLOBS,
|
|
61215
|
-
exclude: EXCLUDES2
|
|
61216
|
-
});
|
|
61217
|
-
if (pomsResult.ok) {
|
|
61218
|
-
dependencyConfigFiles = collectDependencyConfigFiles(
|
|
61219
|
-
pomsResult.value.map((f) => ({ absolutePath: f.absolutePath, content: f.content }))
|
|
61220
|
-
).map((f) => ({ file: f.path, content: f.content }));
|
|
61382
|
+
const rawPlan = planServicePackage(repoRoot, modulePath);
|
|
61383
|
+
if (rawPlan.entries.length === 0) {
|
|
61384
|
+
process.stderr.write(`cs package: no files found under ${modulePath}
|
|
61385
|
+
`);
|
|
61386
|
+
return 2;
|
|
61221
61387
|
}
|
|
61222
|
-
const
|
|
61223
|
-
|
|
61224
|
-
include: JAVA_GLOBS2,
|
|
61225
|
-
exclude: EXCLUDES2
|
|
61226
|
-
});
|
|
61227
|
-
const endpoints = javaResult.ok ? extractHttpEndpoints(javaResult.value).map((e) => ({
|
|
61228
|
-
httpMethod: e.httpMethod,
|
|
61229
|
-
path: e.path
|
|
61230
|
-
})) : [];
|
|
61231
|
-
const authSources = javaResult.ok ? javaResult.value.filter((f) => AUTH_SOURCE_RE.test(f.path) || AUTH_SOURCE_RE.test(f.content)).slice(0, MAX_SOURCE_EXCERPTS).map((f) => ({ file: f.path, content: f.content })) : [];
|
|
61232
|
-
const pomRefs = pomsResult.ok ? pomsResult.value.map((f) => ({ absolutePath: f.absolutePath, content: f.content })) : [];
|
|
61233
|
-
const dependencyJarKeys = collectJwtKeyCandidates(pomRefs);
|
|
61234
|
-
const decodeOnlyEvidence = collectDecodeOnlyEvidence(pomRefs);
|
|
61235
|
-
const dependencyClasses = collectDependencyClassNames(pomRefs);
|
|
61236
|
-
const dependencyConstants = collectDependencyClassConstants(
|
|
61237
|
-
pomRefs,
|
|
61238
|
-
(entry) => AUTH_CLASS_RE.test(simpleClassName2(entry))
|
|
61388
|
+
const cleanEntries = rawPlan.entries.filter(
|
|
61389
|
+
(e) => e.name !== HYPOTHESIS_ENTRY && e.name !== DATA_SEED_HYPOTHESIS_ENTRY && e.name !== AI_TRIAGE_ENTRY && !e.name.startsWith(".code-sentinel/")
|
|
61239
61390
|
);
|
|
61240
|
-
const
|
|
61241
|
-
const
|
|
61242
|
-
|
|
61243
|
-
dependencyConfigFiles,
|
|
61244
|
-
authSources,
|
|
61245
|
-
dependencyClasses,
|
|
61246
|
-
dependencyConstants
|
|
61391
|
+
const plan = { ...rawPlan, entries: cleanEntries };
|
|
61392
|
+
const outPath = resolve(
|
|
61393
|
+
options.out ?? `${basename(plan.modulePath.replace(/\/$/, "")) || "service"}.zip`
|
|
61247
61394
|
);
|
|
61248
|
-
const
|
|
61249
|
-
|
|
61250
|
-
|
|
61395
|
+
const bytes = writePackageZip(plan, outPath);
|
|
61396
|
+
process.stdout.write(`Packaged ${plan.modulePath} \u2192 ${outPath} (${formatBytes(bytes)})
|
|
61397
|
+
`);
|
|
61398
|
+
process.stdout.write(` ${plan.entries.length} files
|
|
61399
|
+
`);
|
|
61400
|
+
if (plan.parentPoms.length > 0) {
|
|
61401
|
+
process.stdout.write(` parent poms: ${plan.parentPoms.join(", ")}
|
|
61402
|
+
`);
|
|
61251
61403
|
}
|
|
61252
|
-
|
|
61253
|
-
|
|
61254
|
-
|
|
61255
|
-
const path = resolve(process.cwd(), options.hypothesis);
|
|
61256
|
-
const read = await readHypothesisFile(path);
|
|
61257
|
-
if (!read.ok) {
|
|
61258
|
-
console.error(
|
|
61259
|
-
`[auth-seed] Kh\xF4ng \u0111\u1ECDc \u0111\u01B0\u1EE3c gi\u1EA3 thuy\u1EBFt t\u1EEB ${options.hypothesis} (${read.error}) \u2192 b\u1ECF.`
|
|
61260
|
-
);
|
|
61261
|
-
preResolved = { hypothesis: null, outcome: "no-proposal" };
|
|
61262
|
-
} else {
|
|
61263
|
-
const validated = validateRuntimeAuthHypothesis(read.result.hypothesis);
|
|
61264
|
-
const { provenance: provenance2 } = read.result;
|
|
61265
|
-
const decision = resolveHypothesisProvenance({
|
|
61266
|
-
policy: provenancePolicy,
|
|
61267
|
-
provenance: provenance2,
|
|
61268
|
-
expectedInputHash: hypothesisInputHash(
|
|
61269
|
-
buildHypothesisInput({
|
|
61270
|
-
kind: "runtime-auth",
|
|
61271
|
-
promptVersion: RUNTIME_AUTH_PROMPT_VERSION,
|
|
61272
|
-
provider: provenance2?.provider ?? "",
|
|
61273
|
-
modelId: provenance2?.modelId ?? "",
|
|
61274
|
-
excerpts,
|
|
61275
|
-
endpoints,
|
|
61276
|
-
signingKeyAvailable
|
|
61277
|
-
})
|
|
61278
|
-
)
|
|
61279
|
-
});
|
|
61280
|
-
console.error(`[auth-seed] ${describeHypothesisProvenance(provenance2, decision)}`);
|
|
61281
|
-
const accepted = decision.useHypothesis ? validated : null;
|
|
61282
|
-
preResolved = {
|
|
61283
|
-
hypothesis: accepted,
|
|
61284
|
-
outcome: accepted === null ? "rejected" : "accepted"
|
|
61285
|
-
};
|
|
61286
|
-
console.error(
|
|
61287
|
-
validated === null ? `[auth-seed] Gi\u1EA3 thuy\u1EBFt n\u1EA1p t\u1EEB ${options.hypothesis} KH\xD4NG qua \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t (sai h\xECnh d\u1EA1ng) \u2192 b\u1ECF.` : accepted === null ? "[auth-seed] Gi\u1EA3 thuy\u1EBFt h\u1EE3p l\u1EC7 nh\u01B0ng L\u1EC6CH ngu\u1ED3n (ch\xEDnh s\xE1ch enforce) \u2192 qu\xE9t kh\xF4ng x\xE1c th\u1EF1c (ADR-0067)." : `[auth-seed] D\xF9ng gi\u1EA3 thuy\u1EBFt \`${validated.scheme}\` \u0111\xE3 gi\u1EA3i s\u1EB5n ngo\xE0i namespace c\xF4 l\u1EADp (kh\xF4ng g\u1ECDi model \u1EDF \u0111\xE2y).`
|
|
61288
|
-
);
|
|
61289
|
-
}
|
|
61404
|
+
if (plan.systemJars.length > 0) {
|
|
61405
|
+
process.stdout.write(` declared jars: ${plan.systemJars.join(", ")}
|
|
61406
|
+
`);
|
|
61290
61407
|
}
|
|
61291
|
-
|
|
61292
|
-
|
|
61293
|
-
|
|
61294
|
-
|
|
61295
|
-
const logger = createLogger({ level: "warn", destination: "stderr" });
|
|
61296
|
-
const config = await loadConfig(
|
|
61297
|
-
options.config === void 0 ? { cwd: source } : { cwd: source, configPath: resolve(process.cwd(), options.config) }
|
|
61408
|
+
if (plan.missingSystemJars.length > 0) {
|
|
61409
|
+
process.stdout.write(
|
|
61410
|
+
` \u26A0 declared but NOT in the repo: ${plan.missingSystemJars.join(", ")}
|
|
61411
|
+
`
|
|
61298
61412
|
);
|
|
61299
|
-
|
|
61300
|
-
|
|
61301
|
-
|
|
61302
|
-
|
|
61303
|
-
|
|
61304
|
-
|
|
61305
|
-
|
|
61306
|
-
|
|
61307
|
-
|
|
61308
|
-
|
|
61309
|
-
|
|
61310
|
-
|
|
61311
|
-
|
|
61312
|
-
|
|
61413
|
+
}
|
|
61414
|
+
const report2 = preflightArchive(outPath);
|
|
61415
|
+
const decision = classifyPreflight({ ...report2.signals, staticAssessmentCompleted: true });
|
|
61416
|
+
if (!decision.decided) {
|
|
61417
|
+
process.stdout.write("\n\u2713 preflight: ready to build\n");
|
|
61418
|
+
if (options.push && link) {
|
|
61419
|
+
process.stdout.write("\n\u{1F680} \u0110ang \u0111\u1EA9y d\u1EEF li\u1EC7u l\xEAn Dashboard...\n");
|
|
61420
|
+
try {
|
|
61421
|
+
const url = `${serverUrl.replace(/\/+$/, "")}/api/projects/${encodeURIComponent(link.projectId)}/pentest-requests`;
|
|
61422
|
+
const formData = new FormData();
|
|
61423
|
+
formData.append("sourceKind", "archive");
|
|
61424
|
+
formData.append("archive", new Blob([readFileSync(outPath)]), basename(outPath));
|
|
61425
|
+
formData.append("useAi", "true");
|
|
61426
|
+
if (link.codebaseId) {
|
|
61427
|
+
formData.append("repositoryId", link.codebaseId);
|
|
61428
|
+
}
|
|
61429
|
+
const res = await fetch(url, {
|
|
61430
|
+
method: "POST",
|
|
61431
|
+
headers: { authorization: `Bearer ${token}` },
|
|
61432
|
+
body: formData
|
|
61433
|
+
});
|
|
61434
|
+
if (!res.ok) {
|
|
61435
|
+
const text2 = await res.text().catch(() => "");
|
|
61436
|
+
console.error(red(`
|
|
61437
|
+
Server t\u1EEB ch\u1ED1i y\xEAu c\u1EA7u (HTTP ${res.status}): ${text2}`));
|
|
61438
|
+
return 2;
|
|
61439
|
+
}
|
|
61440
|
+
const body = await res.json().catch(() => ({}));
|
|
61441
|
+
const createdId = body.request?.id ?? body.id;
|
|
61442
|
+
console.log(green(`[\u2713] \u0110\u1EA9y th\xE0nh c\xF4ng! \u0110\xE3 t\u1EA1o request ID: ${createdId ?? "unknown"}`));
|
|
61443
|
+
console.log(
|
|
61444
|
+
`\u{1F517} Link theo d\xF5i: ${serverUrl.replace(/\/+$/, "")}/runs?project=${encodeURIComponent(link.projectId)}&type=pentest`
|
|
61445
|
+
);
|
|
61446
|
+
if (body.request?.status === "failed" && body.request.failureReason) {
|
|
61447
|
+
console.error(red(`
|
|
61448
|
+
\u26A0 Y\xEAu c\u1EA7u th\u1EA5t b\u1EA1i: ${body.request.failureReason}`));
|
|
61449
|
+
}
|
|
61450
|
+
} catch (e) {
|
|
61451
|
+
console.error(red(`
|
|
61452
|
+
L\u1ED7i m\u1EA1ng khi upload: ${e instanceof Error ? e.message : String(e)}`));
|
|
61453
|
+
return 2;
|
|
61454
|
+
}
|
|
61313
61455
|
}
|
|
61456
|
+
return 0;
|
|
61314
61457
|
}
|
|
61315
|
-
|
|
61316
|
-
|
|
61317
|
-
|
|
61458
|
+
process.stdout.write(`
|
|
61459
|
+
\u2717 preflight still stops at ${decision.tier} \u2014 ${decision.stopReason}
|
|
61460
|
+
`);
|
|
61461
|
+
for (const evidence17 of report2.evidence.slice(0, 5)) {
|
|
61462
|
+
process.stdout.write(` ${evidence17.source}: ${evidence17.verbatim}
|
|
61463
|
+
`);
|
|
61318
61464
|
}
|
|
61319
|
-
|
|
61320
|
-
|
|
61321
|
-
|
|
61322
|
-
|
|
61323
|
-
|
|
61324
|
-
|
|
61325
|
-
|
|
61326
|
-
|
|
61327
|
-
|
|
61328
|
-
|
|
61329
|
-
|
|
61330
|
-
|
|
61331
|
-
|
|
61332
|
-
|
|
61333
|
-
|
|
61334
|
-
|
|
61335
|
-
|
|
61465
|
+
return 1;
|
|
61466
|
+
};
|
|
61467
|
+
|
|
61468
|
+
// src/commands/report.command.ts
|
|
61469
|
+
init_dist7();
|
|
61470
|
+
init_dist9();
|
|
61471
|
+
init_load();
|
|
61472
|
+
init_exit_codes();
|
|
61473
|
+
var VALID_FORMATS = [
|
|
61474
|
+
"markdown",
|
|
61475
|
+
"markdown-compact",
|
|
61476
|
+
"json",
|
|
61477
|
+
"sarif"
|
|
61478
|
+
];
|
|
61479
|
+
var VALID_GROUP_BY = ["severity", "file", "rule", "category"];
|
|
61480
|
+
var isValidFormat = (s) => VALID_FORMATS.includes(s);
|
|
61481
|
+
var isValidGroupBy = (s) => VALID_GROUP_BY.includes(s);
|
|
61482
|
+
var buildReporter = (format) => {
|
|
61483
|
+
switch (format) {
|
|
61484
|
+
case "markdown":
|
|
61485
|
+
return createMarkdownReporter();
|
|
61486
|
+
case "markdown-compact":
|
|
61487
|
+
return createMarkdownCompactReporter();
|
|
61488
|
+
case "json":
|
|
61489
|
+
return createJsonReporter();
|
|
61490
|
+
case "sarif":
|
|
61491
|
+
return createSarifReporter();
|
|
61492
|
+
}
|
|
61493
|
+
};
|
|
61494
|
+
var runReport = async (options) => {
|
|
61495
|
+
if (typeof options.runId !== "string" || options.runId.length === 0) {
|
|
61496
|
+
console.error(red("Error: run-id is required (use `cs history` to list runs)."));
|
|
61497
|
+
return EXIT.USAGE;
|
|
61498
|
+
}
|
|
61499
|
+
if (options.format !== void 0 && !isValidFormat(options.format)) {
|
|
61336
61500
|
console.error(
|
|
61337
|
-
`
|
|
61501
|
+
red(`Error: invalid --format "${options.format}". Allowed: ${VALID_FORMATS.join(", ")}.`)
|
|
61338
61502
|
);
|
|
61503
|
+
return EXIT.USAGE;
|
|
61339
61504
|
}
|
|
61340
|
-
|
|
61341
|
-
excerpts,
|
|
61342
|
-
endpoints,
|
|
61343
|
-
signingKeyAvailable
|
|
61344
|
-
});
|
|
61345
|
-
const { hypothesis, outcome, rejectedShape } = resolution;
|
|
61346
|
-
if (hypothesis === null) {
|
|
61347
|
-
const why = outcome === "resolver-error" ? "G\u1ECCI PROVIDER TH\u1EA4T B\u1EA0I (m\u1EA1ng/egress/kho\xE1) \u2014 kh\xF4ng ph\u1EA3i model kh\xF4ng t\xECm ra g\xEC; xem d\xF2ng WARN c\u1EE7a resolver ngay tr\xEAn" : outcome === "rejected" ? `model C\xD3 tr\u1EA3 l\u1EDDi nh\u01B0ng KH\xD4NG QUA \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t (sai h\xECnh d\u1EA1ng) \u2014 v\u1EA5n \u0111\u1EC1 schema/prompt, kh\xF4ng ph\u1EA3i m\u1EA1ng. H\xECnh d\u1EA1ng nh\u1EADn \u0111\u01B0\u1EE3c: ${rejectedShape ?? "(kh\xF4ng c\xF3)"}` : "kh\xF4ng c\xF3 \u0111\u1EC1 xu\u1EA5t n\xE0o (resolver t\u1EEB ch\u1ED1i, ho\u1EB7c \u0111ang d\xF9ng resolver r\u1ED7ng)";
|
|
61505
|
+
if (options.groupBy !== void 0 && !isValidGroupBy(options.groupBy)) {
|
|
61348
61506
|
console.error(
|
|
61349
|
-
|
|
61350
|
-
// No file is written, so downstream "no parameter" means "deterministic path" with no
|
|
61351
|
-
// second way to spell it.
|
|
61352
|
-
`[auth-seed] ${why} \u2192 KH\xD4NG ghi gi\u1EA3 thuy\u1EBFt; lane runtime s\u1EBD ch\u1EA1y \u0111\u01B0\u1EDDng t\u1EA5t \u0111\u1ECBnh.`
|
|
61353
|
-
)
|
|
61507
|
+
red(`Error: invalid --group-by "${options.groupBy}". Allowed: ${VALID_GROUP_BY.join(", ")}.`)
|
|
61354
61508
|
);
|
|
61355
|
-
return EXIT.
|
|
61356
|
-
}
|
|
61357
|
-
if (options.emitHypothesis !== void 0) {
|
|
61358
|
-
const out = resolve(process.cwd(), options.emitHypothesis);
|
|
61359
|
-
const provenance2 = pinned?.provenance ?? stampProvenance({
|
|
61360
|
-
input: hypothesisInput,
|
|
61361
|
-
hypothesis,
|
|
61362
|
-
attempts: resolution.attempts ?? 1
|
|
61363
|
-
});
|
|
61364
|
-
await writeEnvelopeFile(out, "runtime-auth", hypothesis, provenance2);
|
|
61365
|
-
if (pinned === null) {
|
|
61366
|
-
const saved = await savePin(inputHash, "runtime-auth", hypothesis, provenance2);
|
|
61367
|
-
if (!saved) {
|
|
61368
|
-
console.error(
|
|
61369
|
-
"[auth-seed] Kh\xF4ng ghi \u0111\u01B0\u1EE3c ghim (cache) \u2192 l\u1EA7n \u0111\xF3ng g\xF3i sau s\u1EBD h\u1ECFi l\u1EA1i model."
|
|
61370
|
-
);
|
|
61371
|
-
}
|
|
61372
|
-
}
|
|
61373
|
-
console.error(
|
|
61374
|
-
`[auth-seed] \u0110\xE3 ghi gi\u1EA3 thuy\u1EBFt \`${hypothesis.scheme}\` ra ${options.emitHypothesis} (ngu\u1ED3n: ${provenance2.provider}/${provenance2.modelId}, ghim ${inputHash.slice(0, 12)}); KH\xD4NG mint v\xE0 KH\xD4NG gieo seed \u1EDF \u0111\xE2y.`
|
|
61375
|
-
);
|
|
61376
|
-
return EXIT.SUCCESS;
|
|
61377
|
-
}
|
|
61378
|
-
const plan = buildRuntimeAuthSeedPlan(hypothesis, {
|
|
61379
|
-
files,
|
|
61380
|
-
dependencyConfigFiles,
|
|
61381
|
-
dependencyJarKeys,
|
|
61382
|
-
decodeOnlyEvidence
|
|
61383
|
-
});
|
|
61384
|
-
if (plan === null) {
|
|
61385
|
-
console.error(
|
|
61386
|
-
`[auth-seed] C\xF3 gi\u1EA3 thuy\u1EBFt (\`${hypothesis.scheme}\`) nh\u01B0ng kh\xF4ng t\xECm \u0111\u01B0\u1EE3c kho\xE1 k\xFD trong ngu\u1ED3n hay jar khai b\xE1o v\xE0 kh\xF4ng c\xF3 b\u1EB1ng ch\u1EE9ng decode-only \u2192 KH\xD4NG gieo seed. K\xFD b\u1EB1ng kho\xE1 t\u1EF1 ch\u1ECDn s\u1EBD b\u1ECB \u1EE9ng d\u1EE5ng t\u1EEB ch\u1ED1i y nh\u01B0 kh\xF4ng k\xFD, nh\u01B0ng l\u1EA1i TR\xD4NG nh\u01B0 m\u1ED9t phi\xEAn h\u1EE3p l\u1EC7.`
|
|
61387
|
-
);
|
|
61388
|
-
return EXIT.SUCCESS;
|
|
61389
|
-
}
|
|
61390
|
-
const result = await applyRuntimeAuthSeed(plan, {
|
|
61391
|
-
host: options.redisHost ?? DEFAULT_REDIS_HOST,
|
|
61392
|
-
port: options.redisPort ?? DEFAULT_REDIS_PORT,
|
|
61393
|
-
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
61394
|
-
});
|
|
61395
|
-
if (!result.ok) {
|
|
61396
|
-
for (const f of result.failures) {
|
|
61397
|
-
console.error(`[auth-seed] L\u1EC7nh th\u1EA5t b\u1EA1i: ${f.command} \u2014 ${f.error}`);
|
|
61398
|
-
}
|
|
61399
|
-
console.error(
|
|
61400
|
-
`[auth-seed] Gieo seed KH\xD4NG tr\u1ECDn v\u1EB9n (${result.applied}/${plan.commands.length}) \u2192 KH\xD4NG ph\xE1t token; qu\xE9t \u1EDF tr\u1EA1ng th\xE1i kh\xF4ng x\xE1c th\u1EF1c.`
|
|
61401
|
-
);
|
|
61402
|
-
return EXIT.SUCCESS;
|
|
61403
|
-
}
|
|
61404
|
-
console.error(
|
|
61405
|
-
`[auth-seed] \u0110\xE3 gieo ${result.applied} kho\xE1 state cho scheme \`${hypothesis.scheme}\`.`
|
|
61406
|
-
);
|
|
61407
|
-
console.error(`[auth-seed] \u0110\u1ED8 L\u1EC6CH: ${plan.deviation}`);
|
|
61408
|
-
process.stdout.write(
|
|
61409
|
-
`${plan.credential.value.startsWith("Bearer ") ? plan.credential.value.slice(7) : plan.credential.value}
|
|
61410
|
-
`
|
|
61411
|
-
);
|
|
61412
|
-
return EXIT.SUCCESS;
|
|
61413
|
-
};
|
|
61414
|
-
|
|
61415
|
-
// src/commands/runtime-data-seed.command.ts
|
|
61416
|
-
init_dist6();
|
|
61417
|
-
init_dist2();
|
|
61418
|
-
init_dist2();
|
|
61419
|
-
init_dist5();
|
|
61420
|
-
init_dist();
|
|
61421
|
-
init_dist4();
|
|
61422
|
-
init_composition();
|
|
61423
|
-
init_load();
|
|
61424
|
-
init_exit_codes();
|
|
61425
|
-
init_find_files();
|
|
61426
|
-
var CONFIG_GLOBS2 = [
|
|
61427
|
-
"**/application*.yml",
|
|
61428
|
-
"**/application*.yaml",
|
|
61429
|
-
"**/application*.properties",
|
|
61430
|
-
"**/bootstrap*.yml",
|
|
61431
|
-
"**/bootstrap*.yaml",
|
|
61432
|
-
"**/bootstrap*.properties"
|
|
61433
|
-
];
|
|
61434
|
-
var DB_BUILD_GLOBS2 = ["**/pom.xml", "**/build.gradle", "**/build.gradle.kts"];
|
|
61435
|
-
var JAVA_GLOBS3 = ["**/*.java"];
|
|
61436
|
-
var SCHEMA_GLOBS = [
|
|
61437
|
-
"**/liquibase/**",
|
|
61438
|
-
"**/flyway/**",
|
|
61439
|
-
"**/db/migration/**",
|
|
61440
|
-
"**/*changelog*.xml",
|
|
61441
|
-
"**/schema.sql",
|
|
61442
|
-
"**/data.sql",
|
|
61443
|
-
"**/import.sql"
|
|
61444
|
-
];
|
|
61445
|
-
var EXCLUDES3 = ["**/node_modules/**", "**/dist/**", "**/target/**"];
|
|
61446
|
-
var ENV_SEED_GLOBS = ["**/.env", "**/*.env"];
|
|
61447
|
-
var MAX_ENV_FILE_BYTES = 1024 * 1024;
|
|
61448
|
-
var MAX_EXCERPTS2 = 40;
|
|
61449
|
-
var ENTITY_RE = /@(Entity|Table)\b/;
|
|
61450
|
-
var buildDataSeedEvidence = (schemaFiles, entityFiles, configs) => [...schemaFiles, ...entityFiles, ...configs].slice(0, MAX_EXCERPTS2);
|
|
61451
|
-
var readEnvSeedFiles = async (root) => {
|
|
61452
|
-
try {
|
|
61453
|
-
const paths = await glob([...ENV_SEED_GLOBS], {
|
|
61454
|
-
cwd: root,
|
|
61455
|
-
ignore: [...EXCLUDES3, "**/.git/**"],
|
|
61456
|
-
onlyFiles: true,
|
|
61457
|
-
dot: true
|
|
61458
|
-
});
|
|
61459
|
-
const files = [];
|
|
61460
|
-
for (const p of paths.sort()) {
|
|
61461
|
-
let content;
|
|
61462
|
-
try {
|
|
61463
|
-
content = await readFile(resolve(root, p), "utf8");
|
|
61464
|
-
} catch {
|
|
61465
|
-
continue;
|
|
61466
|
-
}
|
|
61467
|
-
if (Buffer.byteLength(content, "utf8") > MAX_ENV_FILE_BYTES) continue;
|
|
61468
|
-
const abs = resolve(root, p);
|
|
61469
|
-
files.push({
|
|
61470
|
-
path: toPosix(p),
|
|
61471
|
-
absolutePath: abs,
|
|
61472
|
-
language: languageFromPath(p) ?? "text",
|
|
61473
|
-
content,
|
|
61474
|
-
hash: sha256(content),
|
|
61475
|
-
size: Buffer.byteLength(content, "utf8")
|
|
61476
|
-
});
|
|
61477
|
-
}
|
|
61478
|
-
return files;
|
|
61479
|
-
} catch {
|
|
61480
|
-
return [];
|
|
61481
|
-
}
|
|
61482
|
-
};
|
|
61483
|
-
var runRuntimeDataSeed = async (options) => {
|
|
61484
|
-
if (options.emitHypothesis !== void 0 && options.hypothesis !== void 0) {
|
|
61485
|
-
console.error(
|
|
61486
|
-
"[data-seed] --emit-hypothesis v\xE0 --hypothesis lo\u1EA1i tr\u1EEB nhau: m\u1ED9t b\xEAn GI\u1EA2I (ch\u1EA1y ngo\xE0i namespace c\xF4 l\u1EADp, n\u01A1i c\xF3 egress AI), m\u1ED9t b\xEAn TI\xCAU TH\u1EE4 (ch\u1EA1y trong pod, render SQL)."
|
|
61487
|
-
);
|
|
61488
|
-
return EXIT.USAGE;
|
|
61489
|
-
}
|
|
61490
|
-
if (options.renderSql !== void 0 && options.hypothesis === void 0) {
|
|
61491
|
-
console.error("[data-seed] --render-sql c\u1EA7n --hypothesis (lane ti\xEAu th\u1EE5 trong pod).");
|
|
61492
|
-
return EXIT.USAGE;
|
|
61493
|
-
}
|
|
61494
|
-
if (options.deriveObjectStoreSeed !== void 0 && (options.emitHypothesis !== void 0 || options.hypothesis !== void 0)) {
|
|
61495
|
-
console.error(
|
|
61496
|
-
"[data-seed] --derive-object-store-seed l\xE0 lane \u0111\u1ED9c l\u1EADp (kh\xF4ng g\u1ECDi model, kh\xF4ng c\u1EA7n gi\u1EA3 thuy\u1EBFt) v\xE0 lo\u1EA1i tr\u1EEB --emit-hypothesis / --hypothesis."
|
|
61497
|
-
);
|
|
61498
|
-
return EXIT.USAGE;
|
|
61499
|
-
}
|
|
61500
|
-
const source = resolve(process.cwd(), options.source);
|
|
61501
|
-
const configResult = await findFiles({
|
|
61502
|
-
projectRoot: source,
|
|
61503
|
-
include: CONFIG_GLOBS2,
|
|
61504
|
-
exclude: EXCLUDES3
|
|
61505
|
-
});
|
|
61506
|
-
const configs = configResult.ok ? configResult.value.map((f) => ({ path: f.path, content: f.content })) : [];
|
|
61507
|
-
const buildResult2 = await findFiles({
|
|
61508
|
-
projectRoot: source,
|
|
61509
|
-
include: DB_BUILD_GLOBS2,
|
|
61510
|
-
exclude: EXCLUDES3
|
|
61511
|
-
});
|
|
61512
|
-
const javaResult = await findFiles({
|
|
61513
|
-
projectRoot: source,
|
|
61514
|
-
include: JAVA_GLOBS3,
|
|
61515
|
-
exclude: EXCLUDES3
|
|
61516
|
-
});
|
|
61517
|
-
const javaFiles = javaResult.ok ? javaResult.value : [];
|
|
61518
|
-
const endpoints = javaResult.ok ? extractHttpEndpoints(javaResult.value) : [];
|
|
61519
|
-
if (options.deriveObjectStoreSeed !== void 0) {
|
|
61520
|
-
const poms = buildResult2.ok ? buildResult2.value : [];
|
|
61521
|
-
const envFiles = await readEnvSeedFiles(source);
|
|
61522
|
-
const jarConfigs = collectDependencyConfigFiles(poms);
|
|
61523
|
-
const derivation = deriveObjectStoreSeedTargets([
|
|
61524
|
-
...configResult.ok ? configResult.value : [],
|
|
61525
|
-
...envFiles,
|
|
61526
|
-
...jarConfigs
|
|
61527
|
-
]);
|
|
61528
|
-
if (derivation.targets.length === 0) {
|
|
61529
|
-
console.error(
|
|
61530
|
-
"[data-seed] KH\xD4NG derive \u0111\u01B0\u1EE3c bucket object-store n\xE0o t\u1EEB source (config/jar/.env) \u2192 KH\xD4NG ghi file TSV (fail-closed)."
|
|
61531
|
-
);
|
|
61532
|
-
return EXIT.SUCCESS;
|
|
61533
|
-
}
|
|
61534
|
-
const validated = validateRuntimeDataSeedHypothesis({
|
|
61535
|
-
scheme: "object-put",
|
|
61536
|
-
targets: derivation.targets,
|
|
61537
|
-
evidence: derivation.evidence
|
|
61538
|
-
});
|
|
61539
|
-
if (validated === null || validated.scheme !== "object-put") {
|
|
61540
|
-
console.error(
|
|
61541
|
-
"[data-seed] K\u1EBFt qu\u1EA3 derive KH\xD4NG qua \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t \u2192 KH\xD4NG ghi file TSV (fail-closed)."
|
|
61542
|
-
);
|
|
61543
|
-
return EXIT.SUCCESS;
|
|
61544
|
-
}
|
|
61545
|
-
const tsv = renderObjectStoreSeedTsv(validated);
|
|
61546
|
-
const out = resolve(process.cwd(), options.deriveObjectStoreSeed);
|
|
61547
|
-
await mkdir(resolve(out, ".."), { recursive: true });
|
|
61548
|
-
await writeFile(out, tsv, "utf8");
|
|
61549
|
-
console.error(
|
|
61550
|
-
`[data-seed] \u0110\xE3 derive ${validated.targets.length} bucket object-store (baseline key \`1\`) \u2192 ${options.deriveObjectStoreSeed}.`
|
|
61551
|
-
);
|
|
61552
|
-
return EXIT.SUCCESS;
|
|
61553
|
-
}
|
|
61554
|
-
if (options.emitHypothesis !== void 0) {
|
|
61555
|
-
let resolver = createStubRuntimeDataSeedResolver();
|
|
61556
|
-
let providerName = "none";
|
|
61557
|
-
let modelId = "<none>";
|
|
61558
|
-
if (options.useAi === true) {
|
|
61559
|
-
const logger = createLogger({ level: "warn", destination: "stderr" });
|
|
61560
|
-
const config = await loadConfig(
|
|
61561
|
-
options.config === void 0 ? { cwd: source } : { cwd: source, configPath: resolve(process.cwd(), options.config) }
|
|
61562
|
-
);
|
|
61563
|
-
const client = config.ok ? buildAiClient(config.value.config, logger) : null;
|
|
61564
|
-
if (!config.ok) {
|
|
61565
|
-
console.error(
|
|
61566
|
-
`[data-seed] KH\xD4NG N\u1EA0P \u0110\u01AF\u1EE2C CONFIG (${config.error.message.split(String.fromCharCode(10))[0]}) \u2192 d\xF9ng resolver r\u1ED7ng. \u0110\xE2y l\xE0 l\u1ED7i FILE C\u1EA4U H\xCCNH, kh\xF4ng ph\u1EA3i thi\u1EBFu provider.`
|
|
61567
|
-
);
|
|
61568
|
-
} else if (client === null) {
|
|
61569
|
-
console.error(
|
|
61570
|
-
"\u26A0\uFE0F [Local] Kh\xF4ng t\xECm th\u1EA5y `LLM_API_KEY` \u1EDF file `.env` t\u1EA1i m\xE1y c\u1EE7a b\u1EA1n. B\u1ECF qua b\u01B0\u1EDBc t\u1EA1o d\u1EEF li\u1EC7u gi\u1EA3 l\u1EADp (Data-seed). (N\u1EBFu \u0111\u1EA9y l\xEAn Server, Server s\u1EBD t\u1EF1 d\xF9ng Project AI Key c\u1EE7a n\xF3)."
|
|
61571
|
-
);
|
|
61572
|
-
} else {
|
|
61573
|
-
const resolverOptions = { client, logger };
|
|
61574
|
-
resolver = createRuntimeDataSeedResolver(resolverOptions);
|
|
61575
|
-
providerName = client.name;
|
|
61576
|
-
modelId = resolveActiveModel(config.value.config);
|
|
61577
|
-
console.error(`[data-seed] H\u1ECFi gi\u1EA3 thuy\u1EBFt d\u1EEF li\u1EC7u qua ${client.name} (model ${modelId}).`);
|
|
61578
|
-
}
|
|
61579
|
-
}
|
|
61580
|
-
const manifest = buildReachabilityManifest(endpoints, {});
|
|
61581
|
-
const endpointSummaries = dataSeedEndpointSummaries(manifest.entries);
|
|
61582
|
-
const schemaResult = await findFiles({
|
|
61583
|
-
projectRoot: source,
|
|
61584
|
-
include: SCHEMA_GLOBS,
|
|
61585
|
-
exclude: EXCLUDES3
|
|
61586
|
-
});
|
|
61587
|
-
const schemaFiles = schemaResult.ok ? schemaResult.value.map((f) => ({ path: f.path, content: f.content })) : [];
|
|
61588
|
-
const entityFiles = javaFiles.filter((f) => ENTITY_RE.test(f.content)).map((f) => ({ path: f.path, content: f.content }));
|
|
61589
|
-
const excerpts = buildDataSeedEvidence(schemaFiles, entityFiles, configs);
|
|
61590
|
-
if (options.useAi === true) {
|
|
61591
|
-
const chars = excerpts.reduce((n, e) => n + e.content.length, 0);
|
|
61592
|
-
console.error(
|
|
61593
|
-
`[data-seed] B\u1EB1ng ch\u1EE9ng: ${excerpts.length} excerpt \xB7 ${chars} k\xFD t\u1EF1 \xB7 ${endpointSummaries.length} endpoint c\u1EA7n seed.`
|
|
61594
|
-
);
|
|
61595
|
-
}
|
|
61596
|
-
const hypothesisInput = buildHypothesisInput({
|
|
61597
|
-
kind: "runtime-data-seed",
|
|
61598
|
-
promptVersion: RUNTIME_DATA_SEED_PROMPT_VERSION,
|
|
61599
|
-
provider: providerName,
|
|
61600
|
-
modelId,
|
|
61601
|
-
excerpts,
|
|
61602
|
-
endpoints: endpointSummaries.map((e) => ({ httpMethod: e.httpMethod, path: e.path }))
|
|
61603
|
-
});
|
|
61604
|
-
const inputHash = hypothesisInputHash(hypothesisInput);
|
|
61605
|
-
const pinned = options.refreshHypothesis === true ? null : await loadPin(inputHash);
|
|
61606
|
-
const pinnedHypothesis = pinned === null ? null : validateRuntimeDataSeedHypothesis(pinned.hypothesis);
|
|
61607
|
-
if (pinned !== null && pinnedHypothesis === null) {
|
|
61608
|
-
console.error(
|
|
61609
|
-
"[data-seed] C\xE2u tr\u1EA3 l\u1EDDi \u0111\xE3 ghim KH\xD4NG qua \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t \u2192 b\u1ECF ghim, h\u1ECFi l\u1EA1i model."
|
|
61610
|
-
);
|
|
61611
|
-
} else if (pinnedHypothesis !== null) {
|
|
61612
|
-
console.error(
|
|
61613
|
-
`[data-seed] TR\xDANG ghim ${inputHash.slice(0, 12)} \u2014 d\xF9ng l\u1EA1i c\xE2u tr\u1EA3 l\u1EDDi \u0111\xE3 ghim, KH\xD4NG g\u1ECDi model.`
|
|
61614
|
-
);
|
|
61615
|
-
}
|
|
61616
|
-
const resolution = pinnedHypothesis !== null ? { hypothesis: pinnedHypothesis, outcome: "accepted" } : await resolveRuntimeDataSeedHypothesis(resolver, {
|
|
61617
|
-
endpoints: endpointSummaries,
|
|
61618
|
-
excerpts
|
|
61619
|
-
});
|
|
61620
|
-
const { hypothesis, outcome, rejectedShape } = resolution;
|
|
61621
|
-
if (hypothesis === null) {
|
|
61622
|
-
const why = outcome === "resolver-error" ? "G\u1ECCI PROVIDER TH\u1EA4T B\u1EA0I (m\u1EA1ng/egress/kho\xE1) \u2014 kh\xF4ng ph\u1EA3i model kh\xF4ng t\xECm ra g\xEC; xem d\xF2ng WARN c\u1EE7a resolver ngay tr\xEAn" : outcome === "rejected" ? `model C\xD3 tr\u1EA3 l\u1EDDi nh\u01B0ng KH\xD4NG QUA \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t (sai h\xECnh d\u1EA1ng) \u2014 v\u1EA5n \u0111\u1EC1 schema/prompt, kh\xF4ng ph\u1EA3i m\u1EA1ng. H\xECnh d\u1EA1ng nh\u1EADn \u0111\u01B0\u1EE3c: ${rejectedShape ?? "(kh\xF4ng c\xF3)"}` : "kh\xF4ng c\xF3 \u0111\u1EC1 xu\u1EA5t n\xE0o (resolver t\u1EEB ch\u1ED1i, ho\u1EB7c \u0111ang d\xF9ng resolver r\u1ED7ng)";
|
|
61623
|
-
console.error(
|
|
61624
|
-
`[data-seed] ${why} \u2192 KH\xD4NG ghi gi\u1EA3 thuy\u1EBFt; lane runtime s\u1EBD ch\u1EA1y \u0111\u01B0\u1EDDng t\u1EA5t \u0111\u1ECBnh (kh\xF4ng gieo d\u1EEF li\u1EC7u).`
|
|
61625
|
-
);
|
|
61626
|
-
return EXIT.SUCCESS;
|
|
61627
|
-
}
|
|
61628
|
-
const out = resolve(process.cwd(), options.emitHypothesis);
|
|
61629
|
-
const provenance2 = pinned?.provenance ?? stampProvenance({
|
|
61630
|
-
input: hypothesisInput,
|
|
61631
|
-
hypothesis,
|
|
61632
|
-
attempts: resolution.attempts ?? 1
|
|
61633
|
-
});
|
|
61634
|
-
await writeEnvelopeFile(out, "runtime-data-seed", hypothesis, provenance2);
|
|
61635
|
-
if (pinned === null) {
|
|
61636
|
-
const saved = await savePin(inputHash, "runtime-data-seed", hypothesis, provenance2);
|
|
61637
|
-
if (!saved) {
|
|
61638
|
-
console.error(
|
|
61639
|
-
"[data-seed] Kh\xF4ng ghi \u0111\u01B0\u1EE3c ghim (cache) \u2192 l\u1EA7n \u0111\xF3ng g\xF3i sau s\u1EBD h\u1ECFi l\u1EA1i model."
|
|
61640
|
-
);
|
|
61641
|
-
}
|
|
61642
|
-
}
|
|
61643
|
-
console.error(
|
|
61644
|
-
`[data-seed] \u0110\xE3 ghi gi\u1EA3 thuy\u1EBFt \`${hypothesis.scheme}\` (${hypothesis.targets.length} target) ra ${options.emitHypothesis} (ngu\u1ED3n: ${provenance2.provider}/${provenance2.modelId}, ghim ${inputHash.slice(0, 12)}); KH\xD4NG render SQL \u1EDF \u0111\xE2y.`
|
|
61645
|
-
);
|
|
61646
|
-
return EXIT.SUCCESS;
|
|
61647
|
-
}
|
|
61648
|
-
if (options.hypothesis !== void 0) {
|
|
61649
|
-
const path = resolve(process.cwd(), options.hypothesis);
|
|
61650
|
-
let validated = null;
|
|
61651
|
-
const read = await readHypothesisFile(path);
|
|
61652
|
-
if (!read.ok) {
|
|
61653
|
-
console.error(
|
|
61654
|
-
`[data-seed] Kh\xF4ng \u0111\u1ECDc \u0111\u01B0\u1EE3c gi\u1EA3 thuy\u1EBFt t\u1EEB ${options.hypothesis} (${read.error}) \u2192 KH\xD4NG render SQL.`
|
|
61655
|
-
);
|
|
61656
|
-
} else {
|
|
61657
|
-
validated = validateRuntimeDataSeedHypothesis(read.result.hypothesis);
|
|
61658
|
-
const decision = resolveHypothesisProvenance({
|
|
61659
|
-
policy: "warn",
|
|
61660
|
-
provenance: read.result.provenance
|
|
61661
|
-
});
|
|
61662
|
-
console.error(
|
|
61663
|
-
`[data-seed] ${describeHypothesisProvenance(read.result.provenance, decision)}`
|
|
61664
|
-
);
|
|
61665
|
-
if (validated === null) {
|
|
61666
|
-
const problem = describeRuntimeDataSeedHypothesisProblem(read.result.hypothesis);
|
|
61667
|
-
console.error(
|
|
61668
|
-
`[data-seed] Gi\u1EA3 thuy\u1EBFt n\u1EA1p t\u1EEB ${options.hypothesis} KH\xD4NG qua \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t (sai h\xECnh d\u1EA1ng${problem !== null ? `: ${problem}` : ""}) \u2192 KH\xD4NG render SQL.`
|
|
61669
|
-
);
|
|
61670
|
-
} else {
|
|
61671
|
-
console.error(
|
|
61672
|
-
`[data-seed] D\xF9ng gi\u1EA3 thuy\u1EBFt \`${validated.scheme}\` \u0111\xE3 gi\u1EA3i s\u1EB5n ngo\xE0i namespace c\xF4 l\u1EADp (kh\xF4ng g\u1ECDi model \u1EDF \u0111\xE2y).`
|
|
61673
|
-
);
|
|
61674
|
-
}
|
|
61675
|
-
}
|
|
61676
|
-
if (validated === null) return EXIT.SUCCESS;
|
|
61677
|
-
if (validated.scheme === "api-create") {
|
|
61678
|
-
console.error(
|
|
61679
|
-
"[data-seed] Gi\u1EA3 thuy\u1EBFt `api-create` (seed qua API \u1EE9ng d\u1EE5ng, ADR-0082) kh\xF4ng render b\u1EB1ng SQL \u2014 lane c\u1EE7a n\xF3 l\xE0 `cs assess --emit-tests --data-seed` (suite t\u1EF1 replay create qua MockMvc) \u2192 KH\xD4NG render seed SQL \u1EDF \u0111\xE2y."
|
|
61680
|
-
);
|
|
61681
|
-
return EXIT.SUCCESS;
|
|
61682
|
-
}
|
|
61683
|
-
if (validated.scheme !== "sql-insert") {
|
|
61684
|
-
console.error(
|
|
61685
|
-
"[data-seed] Gi\u1EA3 thuy\u1EBFt `object-put` (seed object-store, ADR-0074) kh\xF4ng render b\u1EB1ng SQL \u2014 lane object-store l\xE0 --derive-object-store-seed \u2192 KH\xD4NG gieo seed \u1EDF lane n\xE0y."
|
|
61686
|
-
);
|
|
61687
|
-
return EXIT.SUCCESS;
|
|
61688
|
-
}
|
|
61689
|
-
const auditColumns = detectSeedAuditColumns(javaFiles);
|
|
61690
|
-
const enriched = applySeedAuditColumns(validated, auditColumns);
|
|
61691
|
-
const addedAuditColumns = seedAuditAddedColumns(validated, enriched);
|
|
61692
|
-
if (addedAuditColumns.length > 0) {
|
|
61693
|
-
console.error(
|
|
61694
|
-
`[data-seed] B\u1ED5 sung ${addedAuditColumns.length} c\u1ED9t audit NOT NULL t\u1EEB entity: ${addedAuditColumns.join(", ")} (raw JDBC INSERT kh\xF4ng qua AuditingEntityListener \u2014 tr\xE1nh ERROR 1364).`
|
|
61695
|
-
);
|
|
61696
|
-
}
|
|
61697
|
-
const dbTier = detectDbTier([
|
|
61698
|
-
...configResult.ok ? configResult.value : [],
|
|
61699
|
-
...buildResult2.ok ? buildResult2.value : []
|
|
61700
|
-
]);
|
|
61701
|
-
const dialect = dbTier?.dialect ?? "generic";
|
|
61702
|
-
let sql2;
|
|
61703
|
-
try {
|
|
61704
|
-
sql2 = renderDataSeedSql(enriched, dialect);
|
|
61705
|
-
} catch (e) {
|
|
61706
|
-
console.error(
|
|
61707
|
-
`[data-seed] Render SQL th\u1EA5t b\u1EA1i (${e.message}) \u2192 KH\xD4NG gieo d\u1EEF li\u1EC7u.`
|
|
61708
|
-
);
|
|
61709
|
-
return EXIT.SUCCESS;
|
|
61710
|
-
}
|
|
61711
|
-
const renderOut = options.renderSql;
|
|
61712
|
-
if (renderOut === void 0) return EXIT.USAGE;
|
|
61713
|
-
const out = resolve(process.cwd(), renderOut);
|
|
61714
|
-
await mkdir(resolve(out, ".."), { recursive: true });
|
|
61715
|
-
await writeFile(out, sql2, "utf8");
|
|
61716
|
-
console.error(
|
|
61717
|
-
`[data-seed] \u0110\xE3 render ${validated.targets.length} target \u2192 ${renderOut} (dialect: ${dialect}).`
|
|
61718
|
-
);
|
|
61719
|
-
console.error(`[data-seed] \u0110\u1ED8 L\u1EC6CH: ${runtimeDataSeedDeviationBanner(validated)}`);
|
|
61720
|
-
return EXIT.SUCCESS;
|
|
61721
|
-
}
|
|
61722
|
-
console.error(
|
|
61723
|
-
"[data-seed] Ch\u01B0a ch\u1EC9 \u0111\u1ECBnh vi\u1EC7c c\u1EA7n l\xE0m: d\xF9ng --emit-hypothesis (gi\u1EA3i ngo\xE0i pod, k\xE8m --ai) ho\u1EB7c --hypothesis + --render-sql (ti\xEAu th\u1EE5 trong pod)."
|
|
61724
|
-
);
|
|
61725
|
-
return EXIT.USAGE;
|
|
61726
|
-
};
|
|
61727
|
-
|
|
61728
|
-
// src/commands/package.command.ts
|
|
61729
|
-
init_dist5();
|
|
61730
|
-
var HYPOTHESIS_ENTRY = ".code-sentinel/auth-hypothesis.json";
|
|
61731
|
-
var DATA_SEED_HYPOTHESIS_ENTRY = ".code-sentinel/data-seed-hypothesis.json";
|
|
61732
|
-
var AI_TRIAGE_ENTRY = ".code-sentinel/ai-triage-assessment.json";
|
|
61733
|
-
var formatBytes = (n) => n > 1024 * 1024 ? `${(n / (1024 * 1024)).toFixed(1)} MB` : `${(n / 1024).toFixed(0)} KB`;
|
|
61734
|
-
var runPackageCommand = async (options) => {
|
|
61735
|
-
const targetDirAbs = resolve(
|
|
61736
|
-
options.targetDir && options.targetDir.trim() !== "" ? options.targetDir : options.source && options.source.trim() !== "" ? options.source : "."
|
|
61737
|
-
);
|
|
61738
|
-
const repoRoot = await getRepoRoot(targetDirAbs, { fallbackToCwd: true });
|
|
61739
|
-
let modulePath = options.module;
|
|
61740
|
-
if (modulePath === void 0 || modulePath.trim() === "") {
|
|
61741
|
-
modulePath = relative(repoRoot, targetDirAbs);
|
|
61742
|
-
if (modulePath === "") modulePath = ".";
|
|
61743
|
-
}
|
|
61744
|
-
const plan = planServicePackage(repoRoot, modulePath);
|
|
61745
|
-
if (plan.entries.length === 0) {
|
|
61746
|
-
process.stderr.write(`cs package: no files found under ${modulePath}
|
|
61747
|
-
`);
|
|
61748
|
-
return 2;
|
|
61749
|
-
}
|
|
61750
|
-
let planWithAuth = plan;
|
|
61751
|
-
const resolveAuthLocally = options.resolveAuth === true && !options.push;
|
|
61752
|
-
const resolveAuthOnServer = options.resolveAuth === true && options.push === true;
|
|
61753
|
-
if (resolveAuthOnServer) {
|
|
61754
|
-
const loaded = await loadConfig(
|
|
61755
|
-
options.config === void 0 ? { cwd: repoRoot } : { cwd: repoRoot, configPath: options.config }
|
|
61756
|
-
);
|
|
61757
|
-
if (!loaded.ok) {
|
|
61758
|
-
console.error(red(`
|
|
61759
|
-
L\u1ED7i \u0111\u1ECDc c\u1EA5u h\xECnh: ${loaded.error.message}`));
|
|
61760
|
-
return 2;
|
|
61761
|
-
}
|
|
61762
|
-
const config = loaded.value.config;
|
|
61763
|
-
const link = await new FileWorkspaceLinkStore(repoRoot).read();
|
|
61764
|
-
if (!link) {
|
|
61765
|
-
console.error(
|
|
61766
|
-
red(
|
|
61767
|
-
"\nD\u1EF1 \xE1n ch\u01B0a \u0111\u01B0\u1EE3c li\xEAn k\u1EBFt (link) v\u1EDBi m\xE1y ch\u1EE7! H\xE3y ch\u1EA1y `cs project link` tr\u01B0\u1EDBc khi d\xF9ng `--push`."
|
|
61768
|
-
)
|
|
61769
|
-
);
|
|
61770
|
-
return 2;
|
|
61771
|
-
}
|
|
61772
|
-
const serverUrl = link.serverUrl ?? config.dashboard.serverUrl ?? getDefaultDashboardServerUrl();
|
|
61773
|
-
let token = config.dashboard.token ?? process.env.CODE_SENTINEL_DASHBOARD_TOKEN;
|
|
61774
|
-
if (!token) {
|
|
61775
|
-
try {
|
|
61776
|
-
const store = createPlatformCredentialStore();
|
|
61777
|
-
const credential = await getAuthenticatedCredential({ server: serverUrl, store });
|
|
61778
|
-
token = credential.accessToken;
|
|
61779
|
-
} catch (e) {
|
|
61780
|
-
console.error(
|
|
61781
|
-
red(
|
|
61782
|
-
`
|
|
61783
|
-
Kh\xF4ng th\u1EC3 l\u1EA5y x\xE1c th\u1EF1c Dashboard: ${e instanceof Error ? e.message : String(e)}
|
|
61784
|
-
H\xE3y ch\u1EA1y \`cs auth login\`.`
|
|
61785
|
-
)
|
|
61786
|
-
);
|
|
61787
|
-
return 2;
|
|
61788
|
-
}
|
|
61789
|
-
}
|
|
61790
|
-
try {
|
|
61791
|
-
const configUrl = `${serverUrl.replace(/\/+$/, "")}/api/projects/${encodeURIComponent(link.projectId)}/review-config`;
|
|
61792
|
-
const configRes = await fetch(configUrl, {
|
|
61793
|
-
headers: { authorization: `Bearer ${token}` }
|
|
61794
|
-
});
|
|
61795
|
-
if (configRes.ok) {
|
|
61796
|
-
const payload = await configRes.json();
|
|
61797
|
-
const config2 = payload.config ?? payload;
|
|
61798
|
-
const ai = config2?.ai;
|
|
61799
|
-
const provider = ai?.provider ?? config2?.aiProvider ?? "viettel-netmind";
|
|
61800
|
-
if (provider && provider !== "none" && provider !== "ollama") {
|
|
61801
|
-
const STORED_SECRET_PLACEHOLDER = "${CODE_SENTINEL_STORED_SECRET}";
|
|
61802
|
-
const pKey = provider === "viettel-netmind" ? "viettelNetmind" : provider === "openai-compatible" ? "openaiCompatible" : provider === "opencode-go" ? "opencodeGo" : provider;
|
|
61803
|
-
const providerConf = typeof ai?.[pKey] === "object" && ai?.[pKey] !== null ? ai[pKey] : {};
|
|
61804
|
-
const rawProviderApiKey = typeof providerConf.apiKey === "string" ? providerConf.apiKey.trim() : typeof ai?.apiKey === "string" ? ai.apiKey.trim() : "";
|
|
61805
|
-
const aiStr = JSON.stringify(ai ?? {});
|
|
61806
|
-
const hasServerSecret = aiStr.includes(STORED_SECRET_PLACEHOLDER) || aiStr.includes("<configured server secret>") || rawProviderApiKey === STORED_SECRET_PLACEHOLDER || rawProviderApiKey === "<configured server secret>" || rawProviderApiKey.startsWith("csenc:v1:");
|
|
61807
|
-
const hasExplicitKey = rawProviderApiKey.length > 0 && !hasServerSecret && !/^\$\{[A-Z0-9_]+\}$/.test(rawProviderApiKey);
|
|
61808
|
-
if (!hasServerSecret && !hasExplicitKey) {
|
|
61809
|
-
const drawerUrl = `${serverUrl.replace(/\/+$/, "")}/runs?project=${encodeURIComponent(link.projectId)}&drawer=pentest`;
|
|
61810
|
-
console.error(
|
|
61811
|
-
red("\n\u274C [Server] D\u1EF1 \xE1n ch\u01B0a \u0111\u01B0\u1EE3c c\u1EA5u h\xECnh Project AI Key tr\xEAn Web Dashboard.")
|
|
61812
|
-
);
|
|
61813
|
-
console.error(
|
|
61814
|
-
red(
|
|
61815
|
-
`\u{1F449} Vui l\xF2ng m\u1EDF drawer Pentest tr\xEAn Web Dashboard \u0111\u1EC3 nh\u1EADp API Key:
|
|
61816
|
-
${drawerUrl}
|
|
61817
|
-
`
|
|
61818
|
-
)
|
|
61819
|
-
);
|
|
61820
|
-
console.error(
|
|
61821
|
-
red(
|
|
61822
|
-
`H\u01B0\u1EDBng d\u1EABn thao t\xE1c:
|
|
61823
|
-
1. M\u1EDF link tr\xEAn (ho\u1EB7c v\xE0o D\u1EF1 \xE1n -> b\u1EA5m n\xFAt "Pentest" \u0111\u1EC3 m\u1EDF drawer "Ki\u1EC3m th\u1EED trong m\xF4i tr\u01B0\u1EDDng c\xF4 l\u1EADp").
|
|
61824
|
-
2. T\u1EA1i m\u1EE5c "Project AI Key (${provider})", nh\u1EADp API Key v\xE0 nh\u1EA5n "L\u01B0u key cho d\u1EF1 \xE1n".
|
|
61825
|
-
3. Sau khi l\u01B0u key, ch\u1EA1y l\u1EA1i l\u1EC7nh \`cs pentest\`.
|
|
61826
|
-
|
|
61827
|
-
Ghi ch\xFA: L\u1EC7nh \`cs pentest\` s\u1EED d\u1EE5ng Project AI Key tr\xEAn m\xE1y ch\u1EE7 \u0111\u1EC3 t\u1EF1 \u0111\u1ED9ng th\u1EF1c hi\u1EC7n:
|
|
61828
|
-
- Ph\xE2n t\xEDch & gi\u1EA3i quy\u1EBFt c\u01A1 ch\u1EBF x\xE1c th\u1EF1c (Auth Hypothesis)
|
|
61829
|
-
- Two-Way AI Triage (lo\u1EA1i b\u1ECF False Positive, t\xECm False Negative)
|
|
61830
|
-
- T\u1EA1o d\u1EEF li\u1EC7u m\u1ED3i (Data Seed Hypothesis)
|
|
61831
|
-
`
|
|
61832
|
-
)
|
|
61833
|
-
);
|
|
61834
|
-
return 2;
|
|
61835
|
-
}
|
|
61836
|
-
}
|
|
61837
|
-
}
|
|
61838
|
-
} catch {
|
|
61839
|
-
}
|
|
61840
|
-
}
|
|
61841
|
-
let hypothesisTmp;
|
|
61842
|
-
let triageTmp;
|
|
61843
|
-
if (resolveAuthLocally) {
|
|
61844
|
-
hypothesisTmp = join(tmpdir(), `cs-auth-hypothesis-${process.pid}-${Date.now()}.json`);
|
|
61845
|
-
await runRuntimeAuthSeed({
|
|
61846
|
-
source: join(repoRoot, modulePath),
|
|
61847
|
-
useAi: true,
|
|
61848
|
-
emitHypothesis: hypothesisTmp,
|
|
61849
|
-
...options.refreshHypothesis === true ? { refreshHypothesis: true } : {},
|
|
61850
|
-
...options.config === void 0 ? {} : { config: options.config }
|
|
61851
|
-
});
|
|
61852
|
-
const newEntries = [...plan.entries];
|
|
61853
|
-
if (existsSync(hypothesisTmp)) {
|
|
61854
|
-
newEntries.push({ name: HYPOTHESIS_ENTRY, absolutePath: hypothesisTmp });
|
|
61855
|
-
} else {
|
|
61856
|
-
process.stderr.write(
|
|
61857
|
-
`cs package: kh\xF4ng gi\u1EA3i \u0111\u01B0\u1EE3c gi\u1EA3 thuy\u1EBFt x\xE1c th\u1EF1c \u2014 ZIP kh\xF4ng mang gi\u1EA3 thuy\u1EBFt, lane runtime s\u1EBD ch\u1EA1y \u0111\u01B0\u1EDDng t\u1EA5t \u0111\u1ECBnh${String.fromCharCode(10)}`
|
|
61858
|
-
);
|
|
61859
|
-
}
|
|
61860
|
-
planWithAuth = { ...plan, entries: newEntries };
|
|
61861
|
-
}
|
|
61862
|
-
if (options.resolveAuth === true) {
|
|
61863
|
-
triageTmp = join(tmpdir(), `cs-ai-triage-${process.pid}-${Date.now()}.json`);
|
|
61864
|
-
await runAiTriageCommand({
|
|
61865
|
-
source: join(repoRoot, modulePath),
|
|
61866
|
-
reportRoot: repoRoot,
|
|
61867
|
-
emitReport: triageTmp,
|
|
61868
|
-
twoWay: true,
|
|
61869
|
-
...options.config === void 0 ? {} : { config: options.config }
|
|
61870
|
-
});
|
|
61871
|
-
if (existsSync(triageTmp)) {
|
|
61872
|
-
planWithAuth = {
|
|
61873
|
-
...planWithAuth,
|
|
61874
|
-
entries: [...planWithAuth.entries, { name: AI_TRIAGE_ENTRY, absolutePath: triageTmp }]
|
|
61875
|
-
};
|
|
61876
|
-
} else {
|
|
61877
|
-
process.stderr.write(
|
|
61878
|
-
"[ai-triage] Kh\xF4ng t\u1EA1o \u0111\u01B0\u1EE3c b\xE1o c\xE1o AI triage; ZIP kh\xF4ng mang k\u1EBFt qu\u1EA3 triage.\n"
|
|
61879
|
-
);
|
|
61880
|
-
}
|
|
61881
|
-
}
|
|
61882
|
-
let dataSeedTmp;
|
|
61883
|
-
const resolveDataSeedLocally = options.resolveDataSeed === true && !options.push;
|
|
61884
|
-
if (resolveDataSeedLocally) {
|
|
61885
|
-
dataSeedTmp = join(tmpdir(), `cs-data-seed-${process.pid}-${Date.now()}.json`);
|
|
61886
|
-
await runRuntimeDataSeed({
|
|
61887
|
-
source: join(repoRoot, modulePath),
|
|
61888
|
-
useAi: true,
|
|
61889
|
-
emitHypothesis: dataSeedTmp,
|
|
61890
|
-
...options.refreshHypothesis === true ? { refreshHypothesis: true } : {},
|
|
61891
|
-
...options.config === void 0 ? {} : { config: options.config }
|
|
61892
|
-
});
|
|
61893
|
-
if (existsSync(dataSeedTmp)) {
|
|
61894
|
-
planWithAuth = {
|
|
61895
|
-
...planWithAuth,
|
|
61896
|
-
entries: [
|
|
61897
|
-
...planWithAuth.entries,
|
|
61898
|
-
{ name: DATA_SEED_HYPOTHESIS_ENTRY, absolutePath: dataSeedTmp }
|
|
61899
|
-
]
|
|
61900
|
-
};
|
|
61901
|
-
} else {
|
|
61902
|
-
process.stderr.write(
|
|
61903
|
-
`cs package: kh\xF4ng gi\u1EA3i \u0111\u01B0\u1EE3c gi\u1EA3 thuy\u1EBFt d\u1EEF li\u1EC7u \u2014 ZIP kh\xF4ng mang data-seed, E1.5 s\u1EBD \u0111\u1ECDc baseline-unreachable th\u1EADt${String.fromCharCode(10)}`
|
|
61904
|
-
);
|
|
61905
|
-
}
|
|
61906
|
-
}
|
|
61907
|
-
const outPath = resolve(
|
|
61908
|
-
options.out ?? `${basename(plan.modulePath.replace(/\/$/, "")) || "service"}.zip`
|
|
61909
|
-
);
|
|
61910
|
-
const bytes = writePackageZip(planWithAuth, outPath);
|
|
61911
|
-
if (hypothesisTmp !== void 0) rmSync(hypothesisTmp, { force: true });
|
|
61912
|
-
if (triageTmp !== void 0) rmSync(triageTmp, { force: true });
|
|
61913
|
-
if (dataSeedTmp !== void 0) rmSync(dataSeedTmp, { force: true });
|
|
61914
|
-
process.stdout.write(`Packaged ${plan.modulePath} \u2192 ${outPath} (${formatBytes(bytes)})
|
|
61915
|
-
`);
|
|
61916
|
-
process.stdout.write(` ${planWithAuth.entries.length} files
|
|
61917
|
-
`);
|
|
61918
|
-
if (plan.parentPoms.length > 0) {
|
|
61919
|
-
process.stdout.write(` parent poms: ${plan.parentPoms.join(", ")}
|
|
61920
|
-
`);
|
|
61921
|
-
}
|
|
61922
|
-
if (plan.systemJars.length > 0) {
|
|
61923
|
-
process.stdout.write(` declared jars: ${plan.systemJars.join(", ")}
|
|
61924
|
-
`);
|
|
61925
|
-
}
|
|
61926
|
-
if (plan.missingSystemJars.length > 0) {
|
|
61927
|
-
process.stdout.write(
|
|
61928
|
-
` \u26A0 declared but NOT in the repo: ${plan.missingSystemJars.join(", ")}
|
|
61929
|
-
`
|
|
61930
|
-
);
|
|
61931
|
-
}
|
|
61932
|
-
const report2 = preflightArchive(outPath);
|
|
61933
|
-
const decision = classifyPreflight({ ...report2.signals, staticAssessmentCompleted: true });
|
|
61934
|
-
if (!decision.decided) {
|
|
61935
|
-
process.stdout.write("\n\u2713 preflight: ready to build\n");
|
|
61936
|
-
if (options.push) {
|
|
61937
|
-
process.stdout.write("\n\u{1F680} \u0110ang \u0111\u1EA9y d\u1EEF li\u1EC7u l\xEAn Dashboard...\n");
|
|
61938
|
-
const loaded = await loadConfig(
|
|
61939
|
-
options.config === void 0 ? { cwd: repoRoot } : { cwd: repoRoot, configPath: options.config }
|
|
61940
|
-
);
|
|
61941
|
-
if (!loaded.ok) {
|
|
61942
|
-
console.error(red(`
|
|
61943
|
-
L\u1ED7i \u0111\u1ECDc c\u1EA5u h\xECnh: ${loaded.error.message}`));
|
|
61944
|
-
return 2;
|
|
61945
|
-
}
|
|
61946
|
-
const config = loaded.value.config;
|
|
61947
|
-
const link = await new FileWorkspaceLinkStore(repoRoot).read();
|
|
61948
|
-
if (!link) {
|
|
61949
|
-
console.error(
|
|
61950
|
-
red(
|
|
61951
|
-
"\nD\u1EF1 \xE1n ch\u01B0a \u0111\u01B0\u1EE3c li\xEAn k\u1EBFt (link) v\u1EDBi m\xE1y ch\u1EE7! H\xE3y ch\u1EA1y `cs project link` tr\u01B0\u1EDBc khi d\xF9ng `--push`."
|
|
61952
|
-
)
|
|
61953
|
-
);
|
|
61954
|
-
return 2;
|
|
61955
|
-
}
|
|
61956
|
-
const serverUrl = link.serverUrl ?? config.dashboard.serverUrl ?? getDefaultDashboardServerUrl();
|
|
61957
|
-
let token = config.dashboard.token ?? process.env.CODE_SENTINEL_DASHBOARD_TOKEN;
|
|
61958
|
-
if (!token) {
|
|
61959
|
-
try {
|
|
61960
|
-
const store = createPlatformCredentialStore();
|
|
61961
|
-
const credential = await getAuthenticatedCredential({ server: serverUrl, store });
|
|
61962
|
-
token = credential.accessToken;
|
|
61963
|
-
} catch (e) {
|
|
61964
|
-
console.error(
|
|
61965
|
-
red(
|
|
61966
|
-
`
|
|
61967
|
-
Kh\xF4ng th\u1EC3 l\u1EA5y x\xE1c th\u1EF1c Dashboard: ${e instanceof Error ? e.message : String(e)}
|
|
61968
|
-
H\xE3y ch\u1EA1y \`cs auth login\`.`
|
|
61969
|
-
)
|
|
61970
|
-
);
|
|
61971
|
-
return 2;
|
|
61972
|
-
}
|
|
61973
|
-
}
|
|
61974
|
-
try {
|
|
61975
|
-
const url = `${serverUrl.replace(/\/+$/, "")}/api/projects/${encodeURIComponent(link.projectId)}/pentest-requests`;
|
|
61976
|
-
const { readFileSync: readFileSync3 } = await import('fs');
|
|
61977
|
-
const formData = new FormData();
|
|
61978
|
-
formData.append("sourceKind", "archive");
|
|
61979
|
-
formData.append("archive", new Blob([readFileSync3(outPath)]), basename(outPath));
|
|
61980
|
-
formData.append("useAi", resolveAuthOnServer ? "true" : "false");
|
|
61981
|
-
const res = await fetch(url, {
|
|
61982
|
-
method: "POST",
|
|
61983
|
-
headers: { authorization: `Bearer ${token}` },
|
|
61984
|
-
body: formData
|
|
61985
|
-
});
|
|
61986
|
-
if (!res.ok) {
|
|
61987
|
-
const text2 = await res.text().catch(() => "");
|
|
61988
|
-
console.error(red(`
|
|
61989
|
-
Server t\u1EEB ch\u1ED1i y\xEAu c\u1EA7u (HTTP ${res.status}): ${text2}`));
|
|
61990
|
-
return 2;
|
|
61991
|
-
}
|
|
61992
|
-
const body = await res.json().catch(() => ({}));
|
|
61993
|
-
const createdId = body.request?.id ?? body.id;
|
|
61994
|
-
console.log(green(`[\u2713] \u0110\u1EA9y th\xE0nh c\xF4ng! \u0110\xE3 t\u1EA1o request ID: ${createdId ?? "unknown"}`));
|
|
61995
|
-
console.log(
|
|
61996
|
-
`\u{1F517} Link theo d\xF5i: ${serverUrl}/projects/${link.projectId}/pentest-requests${createdId ? `/${createdId}` : ""}`
|
|
61997
|
-
);
|
|
61998
|
-
if (body.request?.status === "failed" && body.request.failureReason) {
|
|
61999
|
-
console.error(red(`
|
|
62000
|
-
\u26A0 Y\xEAu c\u1EA7u th\u1EA5t b\u1EA1i: ${body.request.failureReason}`));
|
|
62001
|
-
}
|
|
62002
|
-
} catch (e) {
|
|
62003
|
-
console.error(red(`
|
|
62004
|
-
L\u1ED7i m\u1EA1ng khi upload: ${e instanceof Error ? e.message : String(e)}`));
|
|
62005
|
-
return 2;
|
|
62006
|
-
}
|
|
62007
|
-
}
|
|
62008
|
-
return 0;
|
|
62009
|
-
}
|
|
62010
|
-
process.stdout.write(`
|
|
62011
|
-
\u2717 preflight still stops at ${decision.tier} \u2014 ${decision.stopReason}
|
|
62012
|
-
`);
|
|
62013
|
-
for (const evidence17 of report2.evidence.slice(0, 5)) {
|
|
62014
|
-
process.stdout.write(` ${evidence17.source}: ${evidence17.verbatim}
|
|
62015
|
-
`);
|
|
62016
|
-
}
|
|
62017
|
-
return 1;
|
|
62018
|
-
};
|
|
62019
|
-
|
|
62020
|
-
// src/commands/report.command.ts
|
|
62021
|
-
init_dist7();
|
|
62022
|
-
init_dist9();
|
|
62023
|
-
init_load();
|
|
62024
|
-
init_exit_codes();
|
|
62025
|
-
var VALID_FORMATS = [
|
|
62026
|
-
"markdown",
|
|
62027
|
-
"markdown-compact",
|
|
62028
|
-
"json",
|
|
62029
|
-
"sarif"
|
|
62030
|
-
];
|
|
62031
|
-
var VALID_GROUP_BY = ["severity", "file", "rule", "category"];
|
|
62032
|
-
var isValidFormat = (s) => VALID_FORMATS.includes(s);
|
|
62033
|
-
var isValidGroupBy = (s) => VALID_GROUP_BY.includes(s);
|
|
62034
|
-
var buildReporter = (format) => {
|
|
62035
|
-
switch (format) {
|
|
62036
|
-
case "markdown":
|
|
62037
|
-
return createMarkdownReporter();
|
|
62038
|
-
case "markdown-compact":
|
|
62039
|
-
return createMarkdownCompactReporter();
|
|
62040
|
-
case "json":
|
|
62041
|
-
return createJsonReporter();
|
|
62042
|
-
case "sarif":
|
|
62043
|
-
return createSarifReporter();
|
|
62044
|
-
}
|
|
62045
|
-
};
|
|
62046
|
-
var runReport = async (options) => {
|
|
62047
|
-
if (typeof options.runId !== "string" || options.runId.length === 0) {
|
|
62048
|
-
console.error(red("Error: run-id is required (use `cs history` to list runs)."));
|
|
62049
|
-
return EXIT.USAGE;
|
|
62050
|
-
}
|
|
62051
|
-
if (options.format !== void 0 && !isValidFormat(options.format)) {
|
|
62052
|
-
console.error(
|
|
62053
|
-
red(`Error: invalid --format "${options.format}". Allowed: ${VALID_FORMATS.join(", ")}.`)
|
|
62054
|
-
);
|
|
62055
|
-
return EXIT.USAGE;
|
|
62056
|
-
}
|
|
62057
|
-
if (options.groupBy !== void 0 && !isValidGroupBy(options.groupBy)) {
|
|
62058
|
-
console.error(
|
|
62059
|
-
red(`Error: invalid --group-by "${options.groupBy}". Allowed: ${VALID_GROUP_BY.join(", ")}.`)
|
|
62060
|
-
);
|
|
62061
|
-
return EXIT.USAGE;
|
|
61509
|
+
return EXIT.USAGE;
|
|
62062
61510
|
}
|
|
62063
61511
|
const target = resolve(options.path ?? process.cwd());
|
|
62064
61512
|
const loaded = await loadConfig(
|
|
@@ -62116,7 +61564,8 @@ var remoteClient = async (server) => {
|
|
|
62116
61564
|
});
|
|
62117
61565
|
};
|
|
62118
61566
|
var linkedContext = async (path) => {
|
|
62119
|
-
const
|
|
61567
|
+
const resolvedLink = await findWorkspaceLink(resolve(path ?? process.cwd()));
|
|
61568
|
+
const link = resolvedLink?.link ?? null;
|
|
62120
61569
|
if (!link)
|
|
62121
61570
|
throw new Error("This workspace is not linked. Run `cs project` first or pass --project-id.");
|
|
62122
61571
|
return { server: link.serverUrl, projectId: link.projectId };
|
|
@@ -62542,8 +61991,8 @@ var findProjectConfig = async (projectDir) => {
|
|
|
62542
61991
|
);
|
|
62543
61992
|
}
|
|
62544
61993
|
}
|
|
62545
|
-
for (const
|
|
62546
|
-
const p = resolve(projectDir,
|
|
61994
|
+
for (const basename12 of READ_ONLY_BASENAMES) {
|
|
61995
|
+
const p = resolve(projectDir, basename12);
|
|
62547
61996
|
if (await fileExists3(p)) {
|
|
62548
61997
|
return err(
|
|
62549
61998
|
new ConfigInvalidError(
|
|
@@ -62673,7 +62122,8 @@ var runRulePull = async (options = {}) => {
|
|
|
62673
62122
|
const writeError = options.writeError ?? console.error;
|
|
62674
62123
|
const root = resolve(options.path ?? process.cwd());
|
|
62675
62124
|
try {
|
|
62676
|
-
const
|
|
62125
|
+
const resolvedLink = await findWorkspaceLink(root);
|
|
62126
|
+
const link = resolvedLink?.link ?? null;
|
|
62677
62127
|
if (!link) {
|
|
62678
62128
|
writeError("Workspace is not linked. Run `cs project link` before pulling Dashboard rules.");
|
|
62679
62129
|
return EXIT.USAGE;
|
|
@@ -63458,130 +62908,406 @@ var runJob = async (serverUrl, job, options) => {
|
|
|
63458
62908
|
await logPoster.flush();
|
|
63459
62909
|
await rm(root, { recursive: true, force: true });
|
|
63460
62910
|
}
|
|
63461
|
-
};
|
|
63462
|
-
var runServerRunner = async (options = {}) => {
|
|
63463
|
-
const serverUrl = process.env.CODE_SENTINEL_DASHBOARD_URL;
|
|
63464
|
-
const runnerTokenFile = process.env.CODE_SENTINEL_RUNNER_SERVICE_ACCOUNT_TOKEN_FILE;
|
|
63465
|
-
if (!serverUrl || !runnerTokenFile) {
|
|
62911
|
+
};
|
|
62912
|
+
var runServerRunner = async (options = {}) => {
|
|
62913
|
+
const serverUrl = process.env.CODE_SENTINEL_DASHBOARD_URL;
|
|
62914
|
+
const runnerTokenFile = process.env.CODE_SENTINEL_RUNNER_SERVICE_ACCOUNT_TOKEN_FILE;
|
|
62915
|
+
if (!serverUrl || !runnerTokenFile) {
|
|
62916
|
+
console.error(
|
|
62917
|
+
red(
|
|
62918
|
+
"CODE_SENTINEL_DASHBOARD_URL and CODE_SENTINEL_RUNNER_SERVICE_ACCOUNT_TOKEN_FILE are required."
|
|
62919
|
+
)
|
|
62920
|
+
);
|
|
62921
|
+
return EXIT.USAGE;
|
|
62922
|
+
}
|
|
62923
|
+
const runnerIdentityToken = async () => {
|
|
62924
|
+
const token = (await readFile(runnerTokenFile, "utf8")).trim();
|
|
62925
|
+
if (!token) throw new Error("runner ServiceAccount token file is empty");
|
|
62926
|
+
return token;
|
|
62927
|
+
};
|
|
62928
|
+
try {
|
|
62929
|
+
await runnerIdentityToken();
|
|
62930
|
+
} catch (error) {
|
|
62931
|
+
console.error(red(`Unable to read runner ServiceAccount token: ${error.message}`));
|
|
62932
|
+
return EXIT.USAGE;
|
|
62933
|
+
}
|
|
62934
|
+
const pod = {
|
|
62935
|
+
podName: process.env.CODE_SENTINEL_RUNNER_POD_NAME?.trim() ?? "",
|
|
62936
|
+
podUid: process.env.CODE_SENTINEL_RUNNER_POD_UID?.trim() ?? "",
|
|
62937
|
+
nodeName: process.env.CODE_SENTINEL_RUNNER_NODE_NAME?.trim() ?? "",
|
|
62938
|
+
podIp: process.env.CODE_SENTINEL_RUNNER_POD_IP?.trim() ?? ""
|
|
62939
|
+
};
|
|
62940
|
+
if (!pod.podName || !pod.podUid || !pod.nodeName || !pod.podIp) {
|
|
62941
|
+
console.error(red("Runner Kubernetes pod metadata is required."));
|
|
62942
|
+
return EXIT.USAGE;
|
|
62943
|
+
}
|
|
62944
|
+
const runnerId = process.env.CODE_SENTINEL_RUNNER_ID || `k8s/${process.env.CODE_SENTINEL_RUNNER_NAMESPACE ?? "code-sentinel"}/${pod.podName}`;
|
|
62945
|
+
const storageId = process.env.CODE_SENTINEL_STORAGE_ID?.trim() || "local";
|
|
62946
|
+
if (!/^[a-z0-9][a-z0-9._-]{0,127}$/.test(storageId)) {
|
|
62947
|
+
console.error(
|
|
62948
|
+
red(
|
|
62949
|
+
"CODE_SENTINEL_STORAGE_ID must be 1-128 lowercase letters, numbers, dots, underscores, or hyphens."
|
|
62950
|
+
)
|
|
62951
|
+
);
|
|
62952
|
+
return EXIT.USAGE;
|
|
62953
|
+
}
|
|
62954
|
+
const concurrency = options.concurrency ?? positiveInt(process.env.CODE_SENTINEL_RUNNER_CONCURRENCY, 2);
|
|
62955
|
+
const pollIntervalMs = options.pollIntervalMs ?? positiveInt(process.env.CODE_SENTINEL_RUNNER_POLL_INTERVAL_MS, 3e3);
|
|
62956
|
+
const heartbeatIntervalMs = options.heartbeatIntervalMs ?? positiveInt(process.env.CODE_SENTINEL_RUNNER_HEARTBEAT_INTERVAL_MS, 5e3);
|
|
62957
|
+
const archiveDownloadTimeoutMs = options.archiveDownloadTimeoutMs ?? positiveInt(
|
|
62958
|
+
process.env.CODE_SENTINEL_RUNNER_ARCHIVE_DOWNLOAD_TIMEOUT_MS,
|
|
62959
|
+
DEFAULT_ARCHIVE_DOWNLOAD_TIMEOUT_MS
|
|
62960
|
+
);
|
|
62961
|
+
const cancelGraceMs = options.cancelGraceMs ?? positiveInt(process.env.CODE_SENTINEL_RUNNER_CANCEL_GRACE_MS, 1e4);
|
|
62962
|
+
const jobTimeoutMs = options.jobTimeoutMs ?? positiveInt(process.env.CODE_SENTINEL_RUNNER_JOB_TIMEOUT_MS, DEFAULT_RUNNER_JOB_TIMEOUT_MS);
|
|
62963
|
+
const requestedJobId = process.env.CODE_SENTINEL_REMOTE_JOB_ID?.trim() || void 0;
|
|
62964
|
+
const active = /* @__PURE__ */ new Set();
|
|
62965
|
+
let stopping = false;
|
|
62966
|
+
process.once("SIGINT", () => {
|
|
62967
|
+
stopping = true;
|
|
62968
|
+
});
|
|
62969
|
+
process.once("SIGTERM", () => {
|
|
62970
|
+
stopping = true;
|
|
62971
|
+
});
|
|
62972
|
+
console.log(
|
|
62973
|
+
`code-sentinel server runner ${runnerId} started (podUid=${pod.podUid}, nodeName=${pod.nodeName}, podIp=${pod.podIp}, storageId=${storageId}, concurrency=${concurrency}, jobTimeoutMs=${jobTimeoutMs})`
|
|
62974
|
+
);
|
|
62975
|
+
while (!stopping) {
|
|
62976
|
+
while (active.size < concurrency && !stopping) {
|
|
62977
|
+
let retryJob = null;
|
|
62978
|
+
try {
|
|
62979
|
+
retryJob = await leaseAiRetryJob(
|
|
62980
|
+
serverUrl,
|
|
62981
|
+
await runnerIdentityToken(),
|
|
62982
|
+
runnerId,
|
|
62983
|
+
storageId,
|
|
62984
|
+
pod
|
|
62985
|
+
);
|
|
62986
|
+
} catch (error) {
|
|
62987
|
+
console.error(yellow(`AI retry lease failed: ${error.message}`));
|
|
62988
|
+
break;
|
|
62989
|
+
}
|
|
62990
|
+
if (retryJob) {
|
|
62991
|
+
const retryTask = runAiRetryJob(
|
|
62992
|
+
serverUrl,
|
|
62993
|
+
runnerIdentityToken,
|
|
62994
|
+
retryJob,
|
|
62995
|
+
heartbeatIntervalMs
|
|
62996
|
+
).catch((error) => {
|
|
62997
|
+
console.error(red(`AI retry ${retryJob.id} failed: ${error.message}`));
|
|
62998
|
+
}).finally(() => {
|
|
62999
|
+
active.delete(retryTask);
|
|
63000
|
+
});
|
|
63001
|
+
active.add(retryTask);
|
|
63002
|
+
continue;
|
|
63003
|
+
}
|
|
63004
|
+
let job = null;
|
|
63005
|
+
try {
|
|
63006
|
+
job = await leaseJob(
|
|
63007
|
+
serverUrl,
|
|
63008
|
+
await runnerIdentityToken(),
|
|
63009
|
+
runnerId,
|
|
63010
|
+
storageId,
|
|
63011
|
+
pod,
|
|
63012
|
+
requestedJobId
|
|
63013
|
+
);
|
|
63014
|
+
} catch (error) {
|
|
63015
|
+
console.error(yellow(`server-run lease failed: ${error.message}`));
|
|
63016
|
+
break;
|
|
63017
|
+
}
|
|
63018
|
+
if (!job) break;
|
|
63019
|
+
const task = runJob(serverUrl, job, {
|
|
63020
|
+
heartbeatIntervalMs,
|
|
63021
|
+
archiveDownloadTimeoutMs,
|
|
63022
|
+
cancelGraceMs,
|
|
63023
|
+
jobTimeoutMs
|
|
63024
|
+
}).catch((error) => {
|
|
63025
|
+
console.error(red(`server-run ${job.requestId} failed: ${error.message}`));
|
|
63026
|
+
}).finally(() => {
|
|
63027
|
+
active.delete(task);
|
|
63028
|
+
});
|
|
63029
|
+
active.add(task);
|
|
63030
|
+
}
|
|
63031
|
+
if (options.once || requestedJobId) break;
|
|
63032
|
+
await new Promise((resolvePromise) => setTimeout(resolvePromise, pollIntervalMs));
|
|
63033
|
+
}
|
|
63034
|
+
await Promise.allSettled(active);
|
|
63035
|
+
return EXIT.SUCCESS;
|
|
63036
|
+
};
|
|
63037
|
+
|
|
63038
|
+
// src/commands/runtime-auth-seed.command.ts
|
|
63039
|
+
init_dist6();
|
|
63040
|
+
init_dist2();
|
|
63041
|
+
init_dist5();
|
|
63042
|
+
init_dist();
|
|
63043
|
+
init_composition();
|
|
63044
|
+
init_load();
|
|
63045
|
+
init_exit_codes();
|
|
63046
|
+
init_find_files();
|
|
63047
|
+
var CONFIG_GLOBS = [
|
|
63048
|
+
"**/application*.yml",
|
|
63049
|
+
"**/application*.yaml",
|
|
63050
|
+
"**/application*.properties",
|
|
63051
|
+
"**/bootstrap*.yml",
|
|
63052
|
+
"**/bootstrap*.yaml",
|
|
63053
|
+
"**/bootstrap*.properties"
|
|
63054
|
+
];
|
|
63055
|
+
var POM_GLOBS = ["**/pom.xml"];
|
|
63056
|
+
var JAVA_GLOBS2 = ["**/*.java"];
|
|
63057
|
+
var EXCLUDES2 = ["**/node_modules/**", "**/dist/**", "**/target/**"];
|
|
63058
|
+
var MAX_EXCERPTS = 40;
|
|
63059
|
+
var AUTH_SOURCE_RE = /(Filter|Interceptor|Security(Config|Configuration)|Authentication|Authoriz|TokenService|TokenProvider|JwtUtil|UserContext|SessionRegistry)/;
|
|
63060
|
+
var AUTH_CLASS_RE = /((Filter|Interceptor|Aspect)$)|^(UserContext|TokenService|TokenProvider|RedisAbstract|RedisKey|SecurityConfig)/;
|
|
63061
|
+
var MAX_CLASS_NAMES = 120;
|
|
63062
|
+
var MAX_SOURCE_EXCERPTS = 12;
|
|
63063
|
+
var simpleClassName2 = (entry) => (entry.split("/").pop() ?? entry).replace(/\.class$/, "");
|
|
63064
|
+
var DEFAULT_REDIS_HOST = "127.0.0.1";
|
|
63065
|
+
var DEFAULT_REDIS_PORT = 6379;
|
|
63066
|
+
var buildEvidence = (configs, bundled, sources, classNames, classConstants = []) => {
|
|
63067
|
+
const relevant = classNames.filter((n) => AUTH_CLASS_RE.test(simpleClassName2(n))).slice(0, MAX_CLASS_NAMES);
|
|
63068
|
+
const out = [];
|
|
63069
|
+
if (relevant.length > 0) {
|
|
63070
|
+
out.push({
|
|
63071
|
+
path: "<declared jars> \u2014 auth-relevant class inventory",
|
|
63072
|
+
content: [
|
|
63073
|
+
"These classes ship inside the jars this project declares. The authentication gate may be",
|
|
63074
|
+
"implemented here rather than in the source tree; name the scheme from these if so.",
|
|
63075
|
+
"",
|
|
63076
|
+
...relevant
|
|
63077
|
+
].join(String.fromCharCode(10))
|
|
63078
|
+
});
|
|
63079
|
+
}
|
|
63080
|
+
for (const c of classConstants) {
|
|
63081
|
+
if (c.constants.length === 0) continue;
|
|
63082
|
+
out.push({
|
|
63083
|
+
path: `${c.entry} \u2014 string constants`,
|
|
63084
|
+
content: c.constants.join(String.fromCharCode(10))
|
|
63085
|
+
});
|
|
63086
|
+
}
|
|
63087
|
+
return [...out, ...sources, ...bundled, ...configs].slice(0, MAX_EXCERPTS).map((f) => "path" in f ? f : { path: f.file, content: f.content });
|
|
63088
|
+
};
|
|
63089
|
+
var runRuntimeAuthSeed = async (options) => {
|
|
63090
|
+
if (options.emitHypothesis !== void 0 && options.hypothesis !== void 0) {
|
|
63091
|
+
console.error(
|
|
63092
|
+
"[auth-seed] --emit-hypothesis v\xE0 --hypothesis lo\u1EA1i tr\u1EEB nhau: m\u1ED9t b\xEAn GI\u1EA2I (ch\u1EA1y ngo\xE0i namespace c\xF4 l\u1EADp), m\u1ED9t b\xEAn TI\xCAU TH\u1EE4 (ch\u1EA1y trong pod)."
|
|
63093
|
+
);
|
|
63094
|
+
return EXIT.USAGE;
|
|
63095
|
+
}
|
|
63096
|
+
const source = resolve(process.cwd(), options.source);
|
|
63097
|
+
const configResult = await findFiles({
|
|
63098
|
+
projectRoot: source,
|
|
63099
|
+
include: CONFIG_GLOBS,
|
|
63100
|
+
exclude: EXCLUDES2
|
|
63101
|
+
});
|
|
63102
|
+
if (!configResult.ok) {
|
|
63103
|
+
console.error(`[auth-seed] Kh\xF4ng \u0111\u1ECDc \u0111\u01B0\u1EE3c c\u1EA5u h\xECnh trong ${source} \u2192 kh\xF4ng gieo seed.`);
|
|
63104
|
+
return EXIT.SUCCESS;
|
|
63105
|
+
}
|
|
63106
|
+
const files = configResult.value.map((f) => ({
|
|
63107
|
+
file: f.path,
|
|
63108
|
+
content: f.content
|
|
63109
|
+
}));
|
|
63110
|
+
let dependencyConfigFiles = [];
|
|
63111
|
+
const pomsResult = await findFiles({
|
|
63112
|
+
projectRoot: source,
|
|
63113
|
+
include: POM_GLOBS,
|
|
63114
|
+
exclude: EXCLUDES2
|
|
63115
|
+
});
|
|
63116
|
+
if (pomsResult.ok) {
|
|
63117
|
+
dependencyConfigFiles = collectDependencyConfigFiles(
|
|
63118
|
+
pomsResult.value.map((f) => ({ absolutePath: f.absolutePath, content: f.content }))
|
|
63119
|
+
).map((f) => ({ file: f.path, content: f.content }));
|
|
63120
|
+
}
|
|
63121
|
+
const javaResult = await findFiles({
|
|
63122
|
+
projectRoot: source,
|
|
63123
|
+
include: JAVA_GLOBS2,
|
|
63124
|
+
exclude: EXCLUDES2
|
|
63125
|
+
});
|
|
63126
|
+
const endpoints = javaResult.ok ? extractHttpEndpoints(javaResult.value).map((e) => ({
|
|
63127
|
+
httpMethod: e.httpMethod,
|
|
63128
|
+
path: e.path
|
|
63129
|
+
})) : [];
|
|
63130
|
+
const authSources = javaResult.ok ? javaResult.value.filter((f) => AUTH_SOURCE_RE.test(f.path) || AUTH_SOURCE_RE.test(f.content)).slice(0, MAX_SOURCE_EXCERPTS).map((f) => ({ file: f.path, content: f.content })) : [];
|
|
63131
|
+
const pomRefs = pomsResult.ok ? pomsResult.value.map((f) => ({ absolutePath: f.absolutePath, content: f.content })) : [];
|
|
63132
|
+
const dependencyJarKeys = collectJwtKeyCandidates(pomRefs);
|
|
63133
|
+
const decodeOnlyEvidence = collectDecodeOnlyEvidence(pomRefs);
|
|
63134
|
+
const dependencyClasses = collectDependencyClassNames(pomRefs);
|
|
63135
|
+
const dependencyConstants = collectDependencyClassConstants(
|
|
63136
|
+
pomRefs,
|
|
63137
|
+
(entry) => AUTH_CLASS_RE.test(simpleClassName2(entry))
|
|
63138
|
+
);
|
|
63139
|
+
const signingKeyAvailable = discoverJwtSigningKeys(files).length > 0 || discoverJwtSigningKeys(dependencyConfigFiles).length > 0 || dependencyJarKeys.length > 0 || decodeOnlyEvidence.length > 0;
|
|
63140
|
+
const excerpts = buildEvidence(
|
|
63141
|
+
files,
|
|
63142
|
+
dependencyConfigFiles,
|
|
63143
|
+
authSources,
|
|
63144
|
+
dependencyClasses,
|
|
63145
|
+
dependencyConstants
|
|
63146
|
+
);
|
|
63147
|
+
const rawPolicy = options.hypothesisProvenance ?? "warn";
|
|
63148
|
+
if (options.hypothesisProvenance !== void 0 && !isProvenancePolicy(rawPolicy)) {
|
|
63149
|
+
console.error(`[auth-seed] --hypothesis-provenance kh\xF4ng h\u1EE3p l\u1EC7 (${rawPolicy}); d\xF9ng 'warn'.`);
|
|
63150
|
+
}
|
|
63151
|
+
const provenancePolicy = isProvenancePolicy(rawPolicy) ? rawPolicy : "warn";
|
|
63152
|
+
let preResolved;
|
|
63153
|
+
if (options.hypothesis !== void 0) {
|
|
63154
|
+
const path = resolve(process.cwd(), options.hypothesis);
|
|
63155
|
+
const read = await readHypothesisFile(path);
|
|
63156
|
+
if (!read.ok) {
|
|
63157
|
+
console.error(
|
|
63158
|
+
`[auth-seed] Kh\xF4ng \u0111\u1ECDc \u0111\u01B0\u1EE3c gi\u1EA3 thuy\u1EBFt t\u1EEB ${options.hypothesis} (${read.error}) \u2192 b\u1ECF.`
|
|
63159
|
+
);
|
|
63160
|
+
preResolved = { hypothesis: null, outcome: "no-proposal" };
|
|
63161
|
+
} else {
|
|
63162
|
+
const validated = validateRuntimeAuthHypothesis(read.result.hypothesis);
|
|
63163
|
+
const { provenance: provenance2 } = read.result;
|
|
63164
|
+
const decision = resolveHypothesisProvenance({
|
|
63165
|
+
policy: provenancePolicy,
|
|
63166
|
+
provenance: provenance2,
|
|
63167
|
+
expectedInputHash: hypothesisInputHash(
|
|
63168
|
+
buildHypothesisInput({
|
|
63169
|
+
kind: "runtime-auth",
|
|
63170
|
+
promptVersion: RUNTIME_AUTH_PROMPT_VERSION,
|
|
63171
|
+
provider: provenance2?.provider ?? "",
|
|
63172
|
+
modelId: provenance2?.modelId ?? "",
|
|
63173
|
+
excerpts,
|
|
63174
|
+
endpoints,
|
|
63175
|
+
signingKeyAvailable
|
|
63176
|
+
})
|
|
63177
|
+
)
|
|
63178
|
+
});
|
|
63179
|
+
console.error(`[auth-seed] ${describeHypothesisProvenance(provenance2, decision)}`);
|
|
63180
|
+
const accepted = decision.useHypothesis ? validated : null;
|
|
63181
|
+
preResolved = {
|
|
63182
|
+
hypothesis: accepted,
|
|
63183
|
+
outcome: accepted === null ? "rejected" : "accepted"
|
|
63184
|
+
};
|
|
63185
|
+
console.error(
|
|
63186
|
+
validated === null ? `[auth-seed] Gi\u1EA3 thuy\u1EBFt n\u1EA1p t\u1EEB ${options.hypothesis} KH\xD4NG qua \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t (sai h\xECnh d\u1EA1ng) \u2192 b\u1ECF.` : accepted === null ? "[auth-seed] Gi\u1EA3 thuy\u1EBFt h\u1EE3p l\u1EC7 nh\u01B0ng L\u1EC6CH ngu\u1ED3n (ch\xEDnh s\xE1ch enforce) \u2192 qu\xE9t kh\xF4ng x\xE1c th\u1EF1c (ADR-0067)." : `[auth-seed] D\xF9ng gi\u1EA3 thuy\u1EBFt \`${validated.scheme}\` \u0111\xE3 gi\u1EA3i s\u1EB5n ngo\xE0i namespace c\xF4 l\u1EADp (kh\xF4ng g\u1ECDi model \u1EDF \u0111\xE2y).`
|
|
63187
|
+
);
|
|
63188
|
+
}
|
|
63189
|
+
}
|
|
63190
|
+
let resolver = createStubRuntimeAuthHypothesisResolver();
|
|
63191
|
+
let providerName = "none";
|
|
63192
|
+
let modelId = "<none>";
|
|
63193
|
+
if (options.useAi === true && preResolved === void 0) {
|
|
63194
|
+
const logger = createLogger({ level: "warn", destination: "stderr" });
|
|
63195
|
+
const config = await loadConfig(
|
|
63196
|
+
options.config === void 0 ? { cwd: source } : { cwd: source, configPath: resolve(process.cwd(), options.config) }
|
|
63197
|
+
);
|
|
63198
|
+
const client = config.ok ? buildAiClient(config.value.config, logger) : null;
|
|
63199
|
+
if (!config.ok) {
|
|
63200
|
+
console.error(
|
|
63201
|
+
`[auth-seed] KH\xD4NG N\u1EA0P \u0110\u01AF\u1EE2C CONFIG (${config.error.message.split(String.fromCharCode(10))[0]}) \u2192 d\xF9ng resolver r\u1ED7ng. \u0110\xE2y l\xE0 l\u1ED7i FILE C\u1EA4U H\xCCNH, kh\xF4ng ph\u1EA3i thi\u1EBFu provider.`
|
|
63202
|
+
);
|
|
63203
|
+
} else if (client === null) {
|
|
63204
|
+
console.error(
|
|
63205
|
+
"[auth-seed] --ai \u0111\u01B0\u1EE3c y\xEAu c\u1EA7u nh\u01B0ng kh\xF4ng c\xF3 provider AI n\xE0o c\u1EA5u h\xECnh \u0111\u01B0\u1EE3c (ai.provider=none ho\u1EB7c thi\u1EBFu key) \u2192 d\xF9ng resolver r\u1ED7ng."
|
|
63206
|
+
);
|
|
63207
|
+
} else {
|
|
63208
|
+
resolver = createRuntimeAuthHypothesisResolver({ client, logger });
|
|
63209
|
+
providerName = client.name;
|
|
63210
|
+
modelId = resolveActiveModel(config.value.config);
|
|
63211
|
+
console.error(`[auth-seed] H\u1ECFi gi\u1EA3 thuy\u1EBFt x\xE1c th\u1EF1c qua ${client.name} (model ${modelId}).`);
|
|
63212
|
+
}
|
|
63213
|
+
}
|
|
63214
|
+
if (options.useAi === true && preResolved === void 0) {
|
|
63215
|
+
const chars = excerpts.reduce((n, e) => n + e.content.length, 0);
|
|
63216
|
+
console.error(`[auth-seed] B\u1EB1ng ch\u1EE9ng: ${excerpts.length} excerpt \xB7 ${chars} k\xFD t\u1EF1.`);
|
|
63217
|
+
}
|
|
63218
|
+
const hypothesisInput = buildHypothesisInput({
|
|
63219
|
+
kind: "runtime-auth",
|
|
63220
|
+
promptVersion: RUNTIME_AUTH_PROMPT_VERSION,
|
|
63221
|
+
provider: providerName,
|
|
63222
|
+
modelId,
|
|
63223
|
+
excerpts,
|
|
63224
|
+
endpoints,
|
|
63225
|
+
signingKeyAvailable
|
|
63226
|
+
});
|
|
63227
|
+
const inputHash = hypothesisInputHash(hypothesisInput);
|
|
63228
|
+
const pinned = preResolved === void 0 && options.refreshHypothesis !== true ? await loadPin(inputHash) : null;
|
|
63229
|
+
const pinnedHypothesis = pinned === null ? null : validateRuntimeAuthHypothesis(pinned.hypothesis);
|
|
63230
|
+
if (pinned !== null && pinnedHypothesis === null) {
|
|
63466
63231
|
console.error(
|
|
63467
|
-
|
|
63468
|
-
|
|
63469
|
-
|
|
63232
|
+
"[auth-seed] C\xE2u tr\u1EA3 l\u1EDDi \u0111\xE3 ghim KH\xD4NG qua \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t \u2192 b\u1ECF ghim, h\u1ECFi l\u1EA1i model."
|
|
63233
|
+
);
|
|
63234
|
+
} else if (pinnedHypothesis !== null) {
|
|
63235
|
+
console.error(
|
|
63236
|
+
`[auth-seed] TR\xDANG ghim ${inputHash.slice(0, 12)} \u2014 d\xF9ng l\u1EA1i c\xE2u tr\u1EA3 l\u1EDDi \u0111\xE3 ghim, KH\xD4NG g\u1ECDi model.`
|
|
63470
63237
|
);
|
|
63471
|
-
return EXIT.USAGE;
|
|
63472
|
-
}
|
|
63473
|
-
const runnerIdentityToken = async () => {
|
|
63474
|
-
const token = (await readFile(runnerTokenFile, "utf8")).trim();
|
|
63475
|
-
if (!token) throw new Error("runner ServiceAccount token file is empty");
|
|
63476
|
-
return token;
|
|
63477
|
-
};
|
|
63478
|
-
try {
|
|
63479
|
-
await runnerIdentityToken();
|
|
63480
|
-
} catch (error) {
|
|
63481
|
-
console.error(red(`Unable to read runner ServiceAccount token: ${error.message}`));
|
|
63482
|
-
return EXIT.USAGE;
|
|
63483
|
-
}
|
|
63484
|
-
const pod = {
|
|
63485
|
-
podName: process.env.CODE_SENTINEL_RUNNER_POD_NAME?.trim() ?? "",
|
|
63486
|
-
podUid: process.env.CODE_SENTINEL_RUNNER_POD_UID?.trim() ?? "",
|
|
63487
|
-
nodeName: process.env.CODE_SENTINEL_RUNNER_NODE_NAME?.trim() ?? "",
|
|
63488
|
-
podIp: process.env.CODE_SENTINEL_RUNNER_POD_IP?.trim() ?? ""
|
|
63489
|
-
};
|
|
63490
|
-
if (!pod.podName || !pod.podUid || !pod.nodeName || !pod.podIp) {
|
|
63491
|
-
console.error(red("Runner Kubernetes pod metadata is required."));
|
|
63492
|
-
return EXIT.USAGE;
|
|
63493
63238
|
}
|
|
63494
|
-
const
|
|
63495
|
-
|
|
63496
|
-
|
|
63239
|
+
const resolution = pinnedHypothesis !== null ? { hypothesis: pinnedHypothesis, outcome: "accepted" } : preResolved !== void 0 ? preResolved : await resolveRuntimeAuthHypothesis(resolver, {
|
|
63240
|
+
excerpts,
|
|
63241
|
+
endpoints,
|
|
63242
|
+
signingKeyAvailable
|
|
63243
|
+
});
|
|
63244
|
+
const { hypothesis, outcome, rejectedShape } = resolution;
|
|
63245
|
+
if (hypothesis === null) {
|
|
63246
|
+
const why = outcome === "resolver-error" ? "G\u1ECCI PROVIDER TH\u1EA4T B\u1EA0I (m\u1EA1ng/egress/kho\xE1) \u2014 kh\xF4ng ph\u1EA3i model kh\xF4ng t\xECm ra g\xEC; xem d\xF2ng WARN c\u1EE7a resolver ngay tr\xEAn" : outcome === "rejected" ? `model C\xD3 tr\u1EA3 l\u1EDDi nh\u01B0ng KH\xD4NG QUA \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t (sai h\xECnh d\u1EA1ng) \u2014 v\u1EA5n \u0111\u1EC1 schema/prompt, kh\xF4ng ph\u1EA3i m\u1EA1ng. H\xECnh d\u1EA1ng nh\u1EADn \u0111\u01B0\u1EE3c: ${rejectedShape ?? "(kh\xF4ng c\xF3)"}` : "kh\xF4ng c\xF3 \u0111\u1EC1 xu\u1EA5t n\xE0o (resolver t\u1EEB ch\u1ED1i, ho\u1EB7c \u0111ang d\xF9ng resolver r\u1ED7ng)";
|
|
63497
63247
|
console.error(
|
|
63498
|
-
|
|
63499
|
-
|
|
63248
|
+
options.emitHypothesis === void 0 ? `[auth-seed] ${why} \u2192 KH\xD4NG gieo seed; qu\xE9t \u1EDF tr\u1EA1ng th\xE1i kh\xF4ng x\xE1c th\u1EF1c (ADR-0067).` : (
|
|
63249
|
+
// No file is written, so downstream "no parameter" means "deterministic path" with no
|
|
63250
|
+
// second way to spell it.
|
|
63251
|
+
`[auth-seed] ${why} \u2192 KH\xD4NG ghi gi\u1EA3 thuy\u1EBFt; lane runtime s\u1EBD ch\u1EA1y \u0111\u01B0\u1EDDng t\u1EA5t \u0111\u1ECBnh.`
|
|
63500
63252
|
)
|
|
63501
63253
|
);
|
|
63502
|
-
return EXIT.
|
|
63254
|
+
return EXIT.SUCCESS;
|
|
63503
63255
|
}
|
|
63504
|
-
|
|
63505
|
-
|
|
63506
|
-
|
|
63507
|
-
|
|
63508
|
-
|
|
63509
|
-
|
|
63510
|
-
|
|
63511
|
-
|
|
63512
|
-
|
|
63513
|
-
|
|
63514
|
-
|
|
63515
|
-
|
|
63516
|
-
|
|
63517
|
-
stopping = true;
|
|
63518
|
-
});
|
|
63519
|
-
process.once("SIGTERM", () => {
|
|
63520
|
-
stopping = true;
|
|
63521
|
-
});
|
|
63522
|
-
console.log(
|
|
63523
|
-
`code-sentinel server runner ${runnerId} started (podUid=${pod.podUid}, nodeName=${pod.nodeName}, podIp=${pod.podIp}, storageId=${storageId}, concurrency=${concurrency}, jobTimeoutMs=${jobTimeoutMs})`
|
|
63524
|
-
);
|
|
63525
|
-
while (!stopping) {
|
|
63526
|
-
while (active.size < concurrency && !stopping) {
|
|
63527
|
-
let retryJob = null;
|
|
63528
|
-
try {
|
|
63529
|
-
retryJob = await leaseAiRetryJob(
|
|
63530
|
-
serverUrl,
|
|
63531
|
-
await runnerIdentityToken(),
|
|
63532
|
-
runnerId,
|
|
63533
|
-
storageId,
|
|
63534
|
-
pod
|
|
63535
|
-
);
|
|
63536
|
-
} catch (error) {
|
|
63537
|
-
console.error(yellow(`AI retry lease failed: ${error.message}`));
|
|
63538
|
-
break;
|
|
63539
|
-
}
|
|
63540
|
-
if (retryJob) {
|
|
63541
|
-
const retryTask = runAiRetryJob(
|
|
63542
|
-
serverUrl,
|
|
63543
|
-
runnerIdentityToken,
|
|
63544
|
-
retryJob,
|
|
63545
|
-
heartbeatIntervalMs
|
|
63546
|
-
).catch((error) => {
|
|
63547
|
-
console.error(red(`AI retry ${retryJob.id} failed: ${error.message}`));
|
|
63548
|
-
}).finally(() => {
|
|
63549
|
-
active.delete(retryTask);
|
|
63550
|
-
});
|
|
63551
|
-
active.add(retryTask);
|
|
63552
|
-
continue;
|
|
63553
|
-
}
|
|
63554
|
-
let job = null;
|
|
63555
|
-
try {
|
|
63556
|
-
job = await leaseJob(
|
|
63557
|
-
serverUrl,
|
|
63558
|
-
await runnerIdentityToken(),
|
|
63559
|
-
runnerId,
|
|
63560
|
-
storageId,
|
|
63561
|
-
pod,
|
|
63562
|
-
requestedJobId
|
|
63256
|
+
if (options.emitHypothesis !== void 0) {
|
|
63257
|
+
const out = resolve(process.cwd(), options.emitHypothesis);
|
|
63258
|
+
const provenance2 = pinned?.provenance ?? stampProvenance({
|
|
63259
|
+
input: hypothesisInput,
|
|
63260
|
+
hypothesis,
|
|
63261
|
+
attempts: resolution.attempts ?? 1
|
|
63262
|
+
});
|
|
63263
|
+
await writeEnvelopeFile(out, "runtime-auth", hypothesis, provenance2);
|
|
63264
|
+
if (pinned === null) {
|
|
63265
|
+
const saved = await savePin(inputHash, "runtime-auth", hypothesis, provenance2);
|
|
63266
|
+
if (!saved) {
|
|
63267
|
+
console.error(
|
|
63268
|
+
"[auth-seed] Kh\xF4ng ghi \u0111\u01B0\u1EE3c ghim (cache) \u2192 l\u1EA7n \u0111\xF3ng g\xF3i sau s\u1EBD h\u1ECFi l\u1EA1i model."
|
|
63563
63269
|
);
|
|
63564
|
-
} catch (error) {
|
|
63565
|
-
console.error(yellow(`server-run lease failed: ${error.message}`));
|
|
63566
|
-
break;
|
|
63567
63270
|
}
|
|
63568
|
-
if (!job) break;
|
|
63569
|
-
const task = runJob(serverUrl, job, {
|
|
63570
|
-
heartbeatIntervalMs,
|
|
63571
|
-
archiveDownloadTimeoutMs,
|
|
63572
|
-
cancelGraceMs,
|
|
63573
|
-
jobTimeoutMs
|
|
63574
|
-
}).catch((error) => {
|
|
63575
|
-
console.error(red(`server-run ${job.requestId} failed: ${error.message}`));
|
|
63576
|
-
}).finally(() => {
|
|
63577
|
-
active.delete(task);
|
|
63578
|
-
});
|
|
63579
|
-
active.add(task);
|
|
63580
63271
|
}
|
|
63581
|
-
|
|
63582
|
-
|
|
63272
|
+
console.error(
|
|
63273
|
+
`[auth-seed] \u0110\xE3 ghi gi\u1EA3 thuy\u1EBFt \`${hypothesis.scheme}\` ra ${options.emitHypothesis} (ngu\u1ED3n: ${provenance2.provider}/${provenance2.modelId}, ghim ${inputHash.slice(0, 12)}); KH\xD4NG mint v\xE0 KH\xD4NG gieo seed \u1EDF \u0111\xE2y.`
|
|
63274
|
+
);
|
|
63275
|
+
return EXIT.SUCCESS;
|
|
63583
63276
|
}
|
|
63584
|
-
|
|
63277
|
+
const plan = buildRuntimeAuthSeedPlan(hypothesis, {
|
|
63278
|
+
files,
|
|
63279
|
+
dependencyConfigFiles,
|
|
63280
|
+
dependencyJarKeys,
|
|
63281
|
+
decodeOnlyEvidence
|
|
63282
|
+
});
|
|
63283
|
+
if (plan === null) {
|
|
63284
|
+
console.error(
|
|
63285
|
+
`[auth-seed] C\xF3 gi\u1EA3 thuy\u1EBFt (\`${hypothesis.scheme}\`) nh\u01B0ng kh\xF4ng t\xECm \u0111\u01B0\u1EE3c kho\xE1 k\xFD trong ngu\u1ED3n hay jar khai b\xE1o v\xE0 kh\xF4ng c\xF3 b\u1EB1ng ch\u1EE9ng decode-only \u2192 KH\xD4NG gieo seed. K\xFD b\u1EB1ng kho\xE1 t\u1EF1 ch\u1ECDn s\u1EBD b\u1ECB \u1EE9ng d\u1EE5ng t\u1EEB ch\u1ED1i y nh\u01B0 kh\xF4ng k\xFD, nh\u01B0ng l\u1EA1i TR\xD4NG nh\u01B0 m\u1ED9t phi\xEAn h\u1EE3p l\u1EC7.`
|
|
63286
|
+
);
|
|
63287
|
+
return EXIT.SUCCESS;
|
|
63288
|
+
}
|
|
63289
|
+
const result = await applyRuntimeAuthSeed(plan, {
|
|
63290
|
+
host: options.redisHost ?? DEFAULT_REDIS_HOST,
|
|
63291
|
+
port: options.redisPort ?? DEFAULT_REDIS_PORT,
|
|
63292
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
|
|
63293
|
+
});
|
|
63294
|
+
if (!result.ok) {
|
|
63295
|
+
for (const f of result.failures) {
|
|
63296
|
+
console.error(`[auth-seed] L\u1EC7nh th\u1EA5t b\u1EA1i: ${f.command} \u2014 ${f.error}`);
|
|
63297
|
+
}
|
|
63298
|
+
console.error(
|
|
63299
|
+
`[auth-seed] Gieo seed KH\xD4NG tr\u1ECDn v\u1EB9n (${result.applied}/${plan.commands.length}) \u2192 KH\xD4NG ph\xE1t token; qu\xE9t \u1EDF tr\u1EA1ng th\xE1i kh\xF4ng x\xE1c th\u1EF1c.`
|
|
63300
|
+
);
|
|
63301
|
+
return EXIT.SUCCESS;
|
|
63302
|
+
}
|
|
63303
|
+
console.error(
|
|
63304
|
+
`[auth-seed] \u0110\xE3 gieo ${result.applied} kho\xE1 state cho scheme \`${hypothesis.scheme}\`.`
|
|
63305
|
+
);
|
|
63306
|
+
console.error(`[auth-seed] \u0110\u1ED8 L\u1EC6CH: ${plan.deviation}`);
|
|
63307
|
+
process.stdout.write(
|
|
63308
|
+
`${plan.credential.value.startsWith("Bearer ") ? plan.credential.value.slice(7) : plan.credential.value}
|
|
63309
|
+
`
|
|
63310
|
+
);
|
|
63585
63311
|
return EXIT.SUCCESS;
|
|
63586
63312
|
};
|
|
63587
63313
|
|
|
@@ -63589,7 +63315,7 @@ var runServerRunner = async (options = {}) => {
|
|
|
63589
63315
|
init_dist5();
|
|
63590
63316
|
init_exit_codes();
|
|
63591
63317
|
init_find_files();
|
|
63592
|
-
var
|
|
63318
|
+
var CONFIG_GLOBS2 = [
|
|
63593
63319
|
"**/application*.yml",
|
|
63594
63320
|
"**/application*.yaml",
|
|
63595
63321
|
"**/application*.properties",
|
|
@@ -63611,7 +63337,7 @@ var runRuntimeAuthToken = async (options) => {
|
|
|
63611
63337
|
const source = resolve(process.cwd(), options.source);
|
|
63612
63338
|
const filesResult = await findFiles({
|
|
63613
63339
|
projectRoot: source,
|
|
63614
|
-
include:
|
|
63340
|
+
include: CONFIG_GLOBS2,
|
|
63615
63341
|
exclude: CONFIG_EXCLUDES
|
|
63616
63342
|
});
|
|
63617
63343
|
if (!filesResult.ok) {
|
|
@@ -63678,6 +63404,319 @@ var runRuntimeAuthToken = async (options) => {
|
|
|
63678
63404
|
return EXIT.SUCCESS;
|
|
63679
63405
|
};
|
|
63680
63406
|
|
|
63407
|
+
// src/commands/runtime-data-seed.command.ts
|
|
63408
|
+
init_dist6();
|
|
63409
|
+
init_dist2();
|
|
63410
|
+
init_dist2();
|
|
63411
|
+
init_dist5();
|
|
63412
|
+
init_dist();
|
|
63413
|
+
init_dist4();
|
|
63414
|
+
init_composition();
|
|
63415
|
+
init_load();
|
|
63416
|
+
init_exit_codes();
|
|
63417
|
+
init_find_files();
|
|
63418
|
+
var CONFIG_GLOBS3 = [
|
|
63419
|
+
"**/application*.yml",
|
|
63420
|
+
"**/application*.yaml",
|
|
63421
|
+
"**/application*.properties",
|
|
63422
|
+
"**/bootstrap*.yml",
|
|
63423
|
+
"**/bootstrap*.yaml",
|
|
63424
|
+
"**/bootstrap*.properties"
|
|
63425
|
+
];
|
|
63426
|
+
var DB_BUILD_GLOBS2 = ["**/pom.xml", "**/build.gradle", "**/build.gradle.kts"];
|
|
63427
|
+
var JAVA_GLOBS3 = ["**/*.java"];
|
|
63428
|
+
var SCHEMA_GLOBS = [
|
|
63429
|
+
"**/liquibase/**",
|
|
63430
|
+
"**/flyway/**",
|
|
63431
|
+
"**/db/migration/**",
|
|
63432
|
+
"**/*changelog*.xml",
|
|
63433
|
+
"**/schema.sql",
|
|
63434
|
+
"**/data.sql",
|
|
63435
|
+
"**/import.sql"
|
|
63436
|
+
];
|
|
63437
|
+
var EXCLUDES3 = ["**/node_modules/**", "**/dist/**", "**/target/**"];
|
|
63438
|
+
var ENV_SEED_GLOBS = ["**/.env", "**/*.env"];
|
|
63439
|
+
var MAX_ENV_FILE_BYTES = 1024 * 1024;
|
|
63440
|
+
var MAX_EXCERPTS2 = 40;
|
|
63441
|
+
var ENTITY_RE = /@(Entity|Table)\b/;
|
|
63442
|
+
var buildDataSeedEvidence = (schemaFiles, entityFiles, configs) => [...schemaFiles, ...entityFiles, ...configs].slice(0, MAX_EXCERPTS2);
|
|
63443
|
+
var readEnvSeedFiles = async (root) => {
|
|
63444
|
+
try {
|
|
63445
|
+
const paths = await glob([...ENV_SEED_GLOBS], {
|
|
63446
|
+
cwd: root,
|
|
63447
|
+
ignore: [...EXCLUDES3, "**/.git/**"],
|
|
63448
|
+
onlyFiles: true,
|
|
63449
|
+
dot: true
|
|
63450
|
+
});
|
|
63451
|
+
const files = [];
|
|
63452
|
+
for (const p of paths.sort()) {
|
|
63453
|
+
let content;
|
|
63454
|
+
try {
|
|
63455
|
+
content = await readFile(resolve(root, p), "utf8");
|
|
63456
|
+
} catch {
|
|
63457
|
+
continue;
|
|
63458
|
+
}
|
|
63459
|
+
if (Buffer.byteLength(content, "utf8") > MAX_ENV_FILE_BYTES) continue;
|
|
63460
|
+
const abs = resolve(root, p);
|
|
63461
|
+
files.push({
|
|
63462
|
+
path: toPosix(p),
|
|
63463
|
+
absolutePath: abs,
|
|
63464
|
+
language: languageFromPath(p) ?? "text",
|
|
63465
|
+
content,
|
|
63466
|
+
hash: sha256(content),
|
|
63467
|
+
size: Buffer.byteLength(content, "utf8")
|
|
63468
|
+
});
|
|
63469
|
+
}
|
|
63470
|
+
return files;
|
|
63471
|
+
} catch {
|
|
63472
|
+
return [];
|
|
63473
|
+
}
|
|
63474
|
+
};
|
|
63475
|
+
var runRuntimeDataSeed = async (options) => {
|
|
63476
|
+
if (options.emitHypothesis !== void 0 && options.hypothesis !== void 0) {
|
|
63477
|
+
console.error(
|
|
63478
|
+
"[data-seed] --emit-hypothesis v\xE0 --hypothesis lo\u1EA1i tr\u1EEB nhau: m\u1ED9t b\xEAn GI\u1EA2I (ch\u1EA1y ngo\xE0i namespace c\xF4 l\u1EADp, n\u01A1i c\xF3 egress AI), m\u1ED9t b\xEAn TI\xCAU TH\u1EE4 (ch\u1EA1y trong pod, render SQL)."
|
|
63479
|
+
);
|
|
63480
|
+
return EXIT.USAGE;
|
|
63481
|
+
}
|
|
63482
|
+
if (options.renderSql !== void 0 && options.hypothesis === void 0) {
|
|
63483
|
+
console.error("[data-seed] --render-sql c\u1EA7n --hypothesis (lane ti\xEAu th\u1EE5 trong pod).");
|
|
63484
|
+
return EXIT.USAGE;
|
|
63485
|
+
}
|
|
63486
|
+
if (options.deriveObjectStoreSeed !== void 0 && (options.emitHypothesis !== void 0 || options.hypothesis !== void 0)) {
|
|
63487
|
+
console.error(
|
|
63488
|
+
"[data-seed] --derive-object-store-seed l\xE0 lane \u0111\u1ED9c l\u1EADp (kh\xF4ng g\u1ECDi model, kh\xF4ng c\u1EA7n gi\u1EA3 thuy\u1EBFt) v\xE0 lo\u1EA1i tr\u1EEB --emit-hypothesis / --hypothesis."
|
|
63489
|
+
);
|
|
63490
|
+
return EXIT.USAGE;
|
|
63491
|
+
}
|
|
63492
|
+
const source = resolve(process.cwd(), options.source);
|
|
63493
|
+
const configResult = await findFiles({
|
|
63494
|
+
projectRoot: source,
|
|
63495
|
+
include: CONFIG_GLOBS3,
|
|
63496
|
+
exclude: EXCLUDES3
|
|
63497
|
+
});
|
|
63498
|
+
const configs = configResult.ok ? configResult.value.map((f) => ({ path: f.path, content: f.content })) : [];
|
|
63499
|
+
const buildResult2 = await findFiles({
|
|
63500
|
+
projectRoot: source,
|
|
63501
|
+
include: DB_BUILD_GLOBS2,
|
|
63502
|
+
exclude: EXCLUDES3
|
|
63503
|
+
});
|
|
63504
|
+
const javaResult = await findFiles({
|
|
63505
|
+
projectRoot: source,
|
|
63506
|
+
include: JAVA_GLOBS3,
|
|
63507
|
+
exclude: EXCLUDES3
|
|
63508
|
+
});
|
|
63509
|
+
const javaFiles = javaResult.ok ? javaResult.value : [];
|
|
63510
|
+
const endpoints = javaResult.ok ? extractHttpEndpoints(javaResult.value) : [];
|
|
63511
|
+
if (options.deriveObjectStoreSeed !== void 0) {
|
|
63512
|
+
const poms = buildResult2.ok ? buildResult2.value : [];
|
|
63513
|
+
const envFiles = await readEnvSeedFiles(source);
|
|
63514
|
+
const jarConfigs = collectDependencyConfigFiles(poms);
|
|
63515
|
+
const derivation = deriveObjectStoreSeedTargets([
|
|
63516
|
+
...configResult.ok ? configResult.value : [],
|
|
63517
|
+
...envFiles,
|
|
63518
|
+
...jarConfigs
|
|
63519
|
+
]);
|
|
63520
|
+
if (derivation.targets.length === 0) {
|
|
63521
|
+
console.error(
|
|
63522
|
+
"[data-seed] KH\xD4NG derive \u0111\u01B0\u1EE3c bucket object-store n\xE0o t\u1EEB source (config/jar/.env) \u2192 KH\xD4NG ghi file TSV (fail-closed)."
|
|
63523
|
+
);
|
|
63524
|
+
return EXIT.SUCCESS;
|
|
63525
|
+
}
|
|
63526
|
+
const validated = validateRuntimeDataSeedHypothesis({
|
|
63527
|
+
scheme: "object-put",
|
|
63528
|
+
targets: derivation.targets,
|
|
63529
|
+
evidence: derivation.evidence
|
|
63530
|
+
});
|
|
63531
|
+
if (validated === null || validated.scheme !== "object-put") {
|
|
63532
|
+
console.error(
|
|
63533
|
+
"[data-seed] K\u1EBFt qu\u1EA3 derive KH\xD4NG qua \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t \u2192 KH\xD4NG ghi file TSV (fail-closed)."
|
|
63534
|
+
);
|
|
63535
|
+
return EXIT.SUCCESS;
|
|
63536
|
+
}
|
|
63537
|
+
const tsv = renderObjectStoreSeedTsv(validated);
|
|
63538
|
+
const out = resolve(process.cwd(), options.deriveObjectStoreSeed);
|
|
63539
|
+
await mkdir(resolve(out, ".."), { recursive: true });
|
|
63540
|
+
await writeFile(out, tsv, "utf8");
|
|
63541
|
+
console.error(
|
|
63542
|
+
`[data-seed] \u0110\xE3 derive ${validated.targets.length} bucket object-store (baseline key \`1\`) \u2192 ${options.deriveObjectStoreSeed}.`
|
|
63543
|
+
);
|
|
63544
|
+
return EXIT.SUCCESS;
|
|
63545
|
+
}
|
|
63546
|
+
if (options.emitHypothesis !== void 0) {
|
|
63547
|
+
let resolver = createStubRuntimeDataSeedResolver();
|
|
63548
|
+
let providerName = "none";
|
|
63549
|
+
let modelId = "<none>";
|
|
63550
|
+
if (options.useAi === true) {
|
|
63551
|
+
const logger = createLogger({ level: "warn", destination: "stderr" });
|
|
63552
|
+
const config = await loadConfig(
|
|
63553
|
+
options.config === void 0 ? { cwd: source } : { cwd: source, configPath: resolve(process.cwd(), options.config) }
|
|
63554
|
+
);
|
|
63555
|
+
const client = config.ok ? buildAiClient(config.value.config, logger) : null;
|
|
63556
|
+
if (!config.ok) {
|
|
63557
|
+
console.error(
|
|
63558
|
+
`[data-seed] KH\xD4NG N\u1EA0P \u0110\u01AF\u1EE2C CONFIG (${config.error.message.split(String.fromCharCode(10))[0]}) \u2192 d\xF9ng resolver r\u1ED7ng. \u0110\xE2y l\xE0 l\u1ED7i FILE C\u1EA4U H\xCCNH, kh\xF4ng ph\u1EA3i thi\u1EBFu provider.`
|
|
63559
|
+
);
|
|
63560
|
+
} else if (client === null) {
|
|
63561
|
+
console.error(
|
|
63562
|
+
"\u26A0\uFE0F [Local] Kh\xF4ng t\xECm th\u1EA5y `LLM_API_KEY` \u1EDF file `.env` t\u1EA1i m\xE1y c\u1EE7a b\u1EA1n. B\u1ECF qua b\u01B0\u1EDBc t\u1EA1o d\u1EEF li\u1EC7u gi\u1EA3 l\u1EADp (Data-seed). (N\u1EBFu \u0111\u1EA9y l\xEAn Server, Server s\u1EBD t\u1EF1 d\xF9ng Project AI Key c\u1EE7a n\xF3)."
|
|
63563
|
+
);
|
|
63564
|
+
} else {
|
|
63565
|
+
const resolverOptions = { client, logger };
|
|
63566
|
+
resolver = createRuntimeDataSeedResolver(resolverOptions);
|
|
63567
|
+
providerName = client.name;
|
|
63568
|
+
modelId = resolveActiveModel(config.value.config);
|
|
63569
|
+
console.error(`[data-seed] H\u1ECFi gi\u1EA3 thuy\u1EBFt d\u1EEF li\u1EC7u qua ${client.name} (model ${modelId}).`);
|
|
63570
|
+
}
|
|
63571
|
+
}
|
|
63572
|
+
const manifest = buildReachabilityManifest(endpoints, {});
|
|
63573
|
+
const endpointSummaries = dataSeedEndpointSummaries(manifest.entries);
|
|
63574
|
+
const schemaResult = await findFiles({
|
|
63575
|
+
projectRoot: source,
|
|
63576
|
+
include: SCHEMA_GLOBS,
|
|
63577
|
+
exclude: EXCLUDES3
|
|
63578
|
+
});
|
|
63579
|
+
const schemaFiles = schemaResult.ok ? schemaResult.value.map((f) => ({ path: f.path, content: f.content })) : [];
|
|
63580
|
+
const entityFiles = javaFiles.filter((f) => ENTITY_RE.test(f.content)).map((f) => ({ path: f.path, content: f.content }));
|
|
63581
|
+
const excerpts = buildDataSeedEvidence(schemaFiles, entityFiles, configs);
|
|
63582
|
+
if (options.useAi === true) {
|
|
63583
|
+
const chars = excerpts.reduce((n, e) => n + e.content.length, 0);
|
|
63584
|
+
console.error(
|
|
63585
|
+
`[data-seed] B\u1EB1ng ch\u1EE9ng: ${excerpts.length} excerpt \xB7 ${chars} k\xFD t\u1EF1 \xB7 ${endpointSummaries.length} endpoint c\u1EA7n seed.`
|
|
63586
|
+
);
|
|
63587
|
+
}
|
|
63588
|
+
const hypothesisInput = buildHypothesisInput({
|
|
63589
|
+
kind: "runtime-data-seed",
|
|
63590
|
+
promptVersion: RUNTIME_DATA_SEED_PROMPT_VERSION,
|
|
63591
|
+
provider: providerName,
|
|
63592
|
+
modelId,
|
|
63593
|
+
excerpts,
|
|
63594
|
+
endpoints: endpointSummaries.map((e) => ({ httpMethod: e.httpMethod, path: e.path }))
|
|
63595
|
+
});
|
|
63596
|
+
const inputHash = hypothesisInputHash(hypothesisInput);
|
|
63597
|
+
const pinned = options.refreshHypothesis === true ? null : await loadPin(inputHash);
|
|
63598
|
+
const pinnedHypothesis = pinned === null ? null : validateRuntimeDataSeedHypothesis(pinned.hypothesis);
|
|
63599
|
+
if (pinned !== null && pinnedHypothesis === null) {
|
|
63600
|
+
console.error(
|
|
63601
|
+
"[data-seed] C\xE2u tr\u1EA3 l\u1EDDi \u0111\xE3 ghim KH\xD4NG qua \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t \u2192 b\u1ECF ghim, h\u1ECFi l\u1EA1i model."
|
|
63602
|
+
);
|
|
63603
|
+
} else if (pinnedHypothesis !== null) {
|
|
63604
|
+
console.error(
|
|
63605
|
+
`[data-seed] TR\xDANG ghim ${inputHash.slice(0, 12)} \u2014 d\xF9ng l\u1EA1i c\xE2u tr\u1EA3 l\u1EDDi \u0111\xE3 ghim, KH\xD4NG g\u1ECDi model.`
|
|
63606
|
+
);
|
|
63607
|
+
}
|
|
63608
|
+
const resolution = pinnedHypothesis !== null ? { hypothesis: pinnedHypothesis, outcome: "accepted" } : await resolveRuntimeDataSeedHypothesis(resolver, {
|
|
63609
|
+
endpoints: endpointSummaries,
|
|
63610
|
+
excerpts
|
|
63611
|
+
});
|
|
63612
|
+
const { hypothesis, outcome, rejectedShape } = resolution;
|
|
63613
|
+
if (hypothesis === null) {
|
|
63614
|
+
const why = outcome === "resolver-error" ? "G\u1ECCI PROVIDER TH\u1EA4T B\u1EA0I (m\u1EA1ng/egress/kho\xE1) \u2014 kh\xF4ng ph\u1EA3i model kh\xF4ng t\xECm ra g\xEC; xem d\xF2ng WARN c\u1EE7a resolver ngay tr\xEAn" : outcome === "rejected" ? `model C\xD3 tr\u1EA3 l\u1EDDi nh\u01B0ng KH\xD4NG QUA \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t (sai h\xECnh d\u1EA1ng) \u2014 v\u1EA5n \u0111\u1EC1 schema/prompt, kh\xF4ng ph\u1EA3i m\u1EA1ng. H\xECnh d\u1EA1ng nh\u1EADn \u0111\u01B0\u1EE3c: ${rejectedShape ?? "(kh\xF4ng c\xF3)"}` : "kh\xF4ng c\xF3 \u0111\u1EC1 xu\u1EA5t n\xE0o (resolver t\u1EEB ch\u1ED1i, ho\u1EB7c \u0111ang d\xF9ng resolver r\u1ED7ng)";
|
|
63615
|
+
console.error(
|
|
63616
|
+
`[data-seed] ${why} \u2192 KH\xD4NG ghi gi\u1EA3 thuy\u1EBFt; lane runtime s\u1EBD ch\u1EA1y \u0111\u01B0\u1EDDng t\u1EA5t \u0111\u1ECBnh (kh\xF4ng gieo d\u1EEF li\u1EC7u).`
|
|
63617
|
+
);
|
|
63618
|
+
return EXIT.SUCCESS;
|
|
63619
|
+
}
|
|
63620
|
+
const out = resolve(process.cwd(), options.emitHypothesis);
|
|
63621
|
+
const provenance2 = pinned?.provenance ?? stampProvenance({
|
|
63622
|
+
input: hypothesisInput,
|
|
63623
|
+
hypothesis,
|
|
63624
|
+
attempts: resolution.attempts ?? 1
|
|
63625
|
+
});
|
|
63626
|
+
await writeEnvelopeFile(out, "runtime-data-seed", hypothesis, provenance2);
|
|
63627
|
+
if (pinned === null) {
|
|
63628
|
+
const saved = await savePin(inputHash, "runtime-data-seed", hypothesis, provenance2);
|
|
63629
|
+
if (!saved) {
|
|
63630
|
+
console.error(
|
|
63631
|
+
"[data-seed] Kh\xF4ng ghi \u0111\u01B0\u1EE3c ghim (cache) \u2192 l\u1EA7n \u0111\xF3ng g\xF3i sau s\u1EBD h\u1ECFi l\u1EA1i model."
|
|
63632
|
+
);
|
|
63633
|
+
}
|
|
63634
|
+
}
|
|
63635
|
+
console.error(
|
|
63636
|
+
`[data-seed] \u0110\xE3 ghi gi\u1EA3 thuy\u1EBFt \`${hypothesis.scheme}\` (${hypothesis.targets.length} target) ra ${options.emitHypothesis} (ngu\u1ED3n: ${provenance2.provider}/${provenance2.modelId}, ghim ${inputHash.slice(0, 12)}); KH\xD4NG render SQL \u1EDF \u0111\xE2y.`
|
|
63637
|
+
);
|
|
63638
|
+
return EXIT.SUCCESS;
|
|
63639
|
+
}
|
|
63640
|
+
if (options.hypothesis !== void 0) {
|
|
63641
|
+
const path = resolve(process.cwd(), options.hypothesis);
|
|
63642
|
+
let validated = null;
|
|
63643
|
+
const read = await readHypothesisFile(path);
|
|
63644
|
+
if (!read.ok) {
|
|
63645
|
+
console.error(
|
|
63646
|
+
`[data-seed] Kh\xF4ng \u0111\u1ECDc \u0111\u01B0\u1EE3c gi\u1EA3 thuy\u1EBFt t\u1EEB ${options.hypothesis} (${read.error}) \u2192 KH\xD4NG render SQL.`
|
|
63647
|
+
);
|
|
63648
|
+
} else {
|
|
63649
|
+
validated = validateRuntimeDataSeedHypothesis(read.result.hypothesis);
|
|
63650
|
+
const decision = resolveHypothesisProvenance({
|
|
63651
|
+
policy: "warn",
|
|
63652
|
+
provenance: read.result.provenance
|
|
63653
|
+
});
|
|
63654
|
+
console.error(
|
|
63655
|
+
`[data-seed] ${describeHypothesisProvenance(read.result.provenance, decision)}`
|
|
63656
|
+
);
|
|
63657
|
+
if (validated === null) {
|
|
63658
|
+
const problem = describeRuntimeDataSeedHypothesisProblem(read.result.hypothesis);
|
|
63659
|
+
console.error(
|
|
63660
|
+
`[data-seed] Gi\u1EA3 thuy\u1EBFt n\u1EA1p t\u1EEB ${options.hypothesis} KH\xD4NG qua \u0111\u01B0\u1EE3c ki\u1EC3m duy\u1EC7t (sai h\xECnh d\u1EA1ng${problem !== null ? `: ${problem}` : ""}) \u2192 KH\xD4NG render SQL.`
|
|
63661
|
+
);
|
|
63662
|
+
} else {
|
|
63663
|
+
console.error(
|
|
63664
|
+
`[data-seed] D\xF9ng gi\u1EA3 thuy\u1EBFt \`${validated.scheme}\` \u0111\xE3 gi\u1EA3i s\u1EB5n ngo\xE0i namespace c\xF4 l\u1EADp (kh\xF4ng g\u1ECDi model \u1EDF \u0111\xE2y).`
|
|
63665
|
+
);
|
|
63666
|
+
}
|
|
63667
|
+
}
|
|
63668
|
+
if (validated === null) return EXIT.SUCCESS;
|
|
63669
|
+
if (validated.scheme === "api-create") {
|
|
63670
|
+
console.error(
|
|
63671
|
+
"[data-seed] Gi\u1EA3 thuy\u1EBFt `api-create` (seed qua API \u1EE9ng d\u1EE5ng, ADR-0082) kh\xF4ng render b\u1EB1ng SQL \u2014 lane c\u1EE7a n\xF3 l\xE0 `cs assess --emit-tests --data-seed` (suite t\u1EF1 replay create qua MockMvc) \u2192 KH\xD4NG render seed SQL \u1EDF \u0111\xE2y."
|
|
63672
|
+
);
|
|
63673
|
+
return EXIT.SUCCESS;
|
|
63674
|
+
}
|
|
63675
|
+
if (validated.scheme !== "sql-insert") {
|
|
63676
|
+
console.error(
|
|
63677
|
+
"[data-seed] Gi\u1EA3 thuy\u1EBFt `object-put` (seed object-store, ADR-0074) kh\xF4ng render b\u1EB1ng SQL \u2014 lane object-store l\xE0 --derive-object-store-seed \u2192 KH\xD4NG gieo seed \u1EDF lane n\xE0y."
|
|
63678
|
+
);
|
|
63679
|
+
return EXIT.SUCCESS;
|
|
63680
|
+
}
|
|
63681
|
+
const auditColumns = detectSeedAuditColumns(javaFiles);
|
|
63682
|
+
const enriched = applySeedAuditColumns(validated, auditColumns);
|
|
63683
|
+
const addedAuditColumns = seedAuditAddedColumns(validated, enriched);
|
|
63684
|
+
if (addedAuditColumns.length > 0) {
|
|
63685
|
+
console.error(
|
|
63686
|
+
`[data-seed] B\u1ED5 sung ${addedAuditColumns.length} c\u1ED9t audit NOT NULL t\u1EEB entity: ${addedAuditColumns.join(", ")} (raw JDBC INSERT kh\xF4ng qua AuditingEntityListener \u2014 tr\xE1nh ERROR 1364).`
|
|
63687
|
+
);
|
|
63688
|
+
}
|
|
63689
|
+
const dbTier = detectDbTier([
|
|
63690
|
+
...configResult.ok ? configResult.value : [],
|
|
63691
|
+
...buildResult2.ok ? buildResult2.value : []
|
|
63692
|
+
]);
|
|
63693
|
+
const dialect = dbTier?.dialect ?? "generic";
|
|
63694
|
+
let sql2;
|
|
63695
|
+
try {
|
|
63696
|
+
sql2 = renderDataSeedSql(enriched, dialect);
|
|
63697
|
+
} catch (e) {
|
|
63698
|
+
console.error(
|
|
63699
|
+
`[data-seed] Render SQL th\u1EA5t b\u1EA1i (${e.message}) \u2192 KH\xD4NG gieo d\u1EEF li\u1EC7u.`
|
|
63700
|
+
);
|
|
63701
|
+
return EXIT.SUCCESS;
|
|
63702
|
+
}
|
|
63703
|
+
const renderOut = options.renderSql;
|
|
63704
|
+
if (renderOut === void 0) return EXIT.USAGE;
|
|
63705
|
+
const out = resolve(process.cwd(), renderOut);
|
|
63706
|
+
await mkdir(resolve(out, ".."), { recursive: true });
|
|
63707
|
+
await writeFile(out, sql2, "utf8");
|
|
63708
|
+
console.error(
|
|
63709
|
+
`[data-seed] \u0110\xE3 render ${validated.targets.length} target \u2192 ${renderOut} (dialect: ${dialect}).`
|
|
63710
|
+
);
|
|
63711
|
+
console.error(`[data-seed] \u0110\u1ED8 L\u1EC6CH: ${runtimeDataSeedDeviationBanner(validated)}`);
|
|
63712
|
+
return EXIT.SUCCESS;
|
|
63713
|
+
}
|
|
63714
|
+
console.error(
|
|
63715
|
+
"[data-seed] Ch\u01B0a ch\u1EC9 \u0111\u1ECBnh vi\u1EC7c c\u1EA7n l\xE0m: d\xF9ng --emit-hypothesis (gi\u1EA3i ngo\xE0i pod, k\xE8m --ai) ho\u1EB7c --hypothesis + --render-sql (ti\xEAu th\u1EE5 trong pod)."
|
|
63716
|
+
);
|
|
63717
|
+
return EXIT.USAGE;
|
|
63718
|
+
};
|
|
63719
|
+
|
|
63681
63720
|
// src/commands/runtime-outcome.command.ts
|
|
63682
63721
|
init_dist2();
|
|
63683
63722
|
init_dist5();
|
|
@@ -65436,7 +65475,9 @@ var buildProgram = () => {
|
|
|
65436
65475
|
...typeof opts.deriveObjectStoreSeed === "string" && opts.deriveObjectStoreSeed.length > 0 ? { deriveObjectStoreSeed: opts.deriveObjectStoreSeed } : {}
|
|
65437
65476
|
});
|
|
65438
65477
|
});
|
|
65439
|
-
program.command("pentest [targetDir]").description(
|
|
65478
|
+
program.command("pentest [targetDir]").description(
|
|
65479
|
+
"\u0110\xF3ng g\xF3i m\xE3 ngu\u1ED3n v\xE0 \u0111\u1EA9y l\xEAn Server Pentest (AI Triage & Auth th\u1EF1c thi tr\xEAn server)"
|
|
65480
|
+
).addOption(new Option("--source <dir>", "th\u01B0 m\u1EE5c g\u1ED1c repository").hideHelp()).addOption(
|
|
65440
65481
|
new Option(
|
|
65441
65482
|
"--module <path>",
|
|
65442
65483
|
"module c\u1EA7n \u0111\xF3ng g\xF3i, \u0111\u01B0\u1EDDng d\u1EABn t\u01B0\u01A1ng \u0111\u1ED1i so v\u1EDBi g\u1ED1c repo"
|
|
@@ -65447,14 +65488,14 @@ var buildProgram = () => {
|
|
|
65447
65488
|
...options,
|
|
65448
65489
|
source: options.source ?? ".",
|
|
65449
65490
|
targetDir,
|
|
65450
|
-
resolveAuth: true,
|
|
65451
|
-
resolveDataSeed: true,
|
|
65452
65491
|
push: true
|
|
65453
65492
|
// Always push by default for pentest
|
|
65454
65493
|
});
|
|
65455
65494
|
}
|
|
65456
65495
|
);
|
|
65457
|
-
program.command("package [targetDir]").description(
|
|
65496
|
+
program.command("package [targetDir]").description(
|
|
65497
|
+
"\u0110\xF3ng g\xF3i M\u1ED8T service (k\xE8m parent pom + jar khai b\xE1o) th\xE0nh ZIP thu\u1EA7n t\xFAy, c\xF3 t\u1EF1 ki\u1EC3m"
|
|
65498
|
+
).addOption(new Option("--source <dir>", "th\u01B0 m\u1EE5c g\u1ED1c repository").hideHelp()).addOption(
|
|
65458
65499
|
new Option(
|
|
65459
65500
|
"--module <path>",
|
|
65460
65501
|
"module c\u1EA7n \u0111\xF3ng g\xF3i, \u0111\u01B0\u1EDDng d\u1EABn t\u01B0\u01A1ng \u0111\u1ED1i so v\u1EDBi g\u1ED1c repo"
|