Class: SnowflakeConnector
Defined in: src/connectors/snowflake.ts:48
Secure Snowflake connector
The host field should be <account>.snowflakecomputing.com; the account
identifier is extracted automatically.
Features:
- SQL injection prevention
- Credential validation
- Read-only query patterns
- Connection timeouts
- Secure error handling
Example
import { SnowflakeConnector } from '@freshguard/freshguard-core';
const connector = new SnowflakeConnector({
host: 'xy12345.us-east-1.snowflakecomputing.com', port: 443,
database: 'ANALYTICS',
username: 'READER',
password: process.env.SF_PASSWORD!,
});
Extends
BaseConnector
Constructors
Constructor
new SnowflakeConnector(
config,securityConfig?):SnowflakeConnector
Defined in: src/connectors/snowflake.ts:62
Parameters
config
ConnectorConfig
Connection config; host is <account>.snowflakecomputing.com.
Pass options.schema to target a specific schema (default: 'PUBLIC').
Pass options.warehouse to specify the compute warehouse.
securityConfig?
Partial<SecurityConfig>
Optional overrides for query timeouts, max rows, and blocked keywords
Returns
SnowflakeConnector
Overrides
BaseConnector.constructor
Properties
config
protectedconfig:ConnectorConfig
Defined in: src/connectors/base-connector.ts:63
Inherited from
BaseConnector.config
connectionTimeout
protectedreadonlyconnectionTimeout:number
Defined in: src/connectors/base-connector.ts:49
Inherited from
BaseConnector.connectionTimeout
enableDetailedLogging
protectedreadonlyenableDetailedLogging:boolean
Defined in: src/connectors/base-connector.ts:57
Inherited from
BaseConnector.enableDetailedLogging
enableQueryAnalysis
protectedreadonlyenableQueryAnalysis:boolean
Defined in: src/connectors/base-connector.ts:58
Inherited from
BaseConnector.enableQueryAnalysis
logger
protectedreadonlylogger:StructuredLogger
Defined in: src/connectors/base-connector.ts:53
Inherited from
BaseConnector.logger
maxRows
protectedreadonlymaxRows:number
Defined in: src/connectors/base-connector.ts:51
Inherited from
BaseConnector.maxRows
metrics
protectedreadonlymetrics:MetricsCollector
Defined in: src/connectors/base-connector.ts:54
Inherited from
BaseConnector.metrics
queryAnalyzer
protectedreadonlyqueryAnalyzer:QueryComplexityAnalyzer
Defined in: src/connectors/base-connector.ts:55
Inherited from
BaseConnector.queryAnalyzer
queryTimeout
protectedreadonlyqueryTimeout:number
Defined in: src/connectors/base-connector.ts:50
Inherited from
BaseConnector.queryTimeout
requireSSL
protectedreadonlyrequireSSL:boolean
Defined in: src/connectors/base-connector.ts:52
Inherited from
BaseConnector.requireSSL
schemaCache
protectedreadonlyschemaCache:SchemaCache
Defined in: src/connectors/base-connector.ts:56
Inherited from
BaseConnector.schemaCache
Methods
cleanup()
protectedcleanup():void
Defined in: src/connectors/base-connector.ts:806
Cleanup resources (should be called by subclasses in their close method)
Returns
void
Inherited from
BaseConnector.cleanup
clearSchemaCache()
protectedclearSchemaCache():void
Defined in: src/connectors/base-connector.ts:792
Clear schema cache for testing or maintenance
Returns
void
Inherited from
BaseConnector.clearSchemaCache
close()
close():
Promise<void>
Defined in: src/connectors/snowflake.ts:471
Close the Snowflake connection
Returns
Promise<void>
Overrides
BaseConnector.close
connectLegacy()
connectLegacy(
credentials):Promise<void>
Defined in: src/connectors/snowflake.ts:574
Legacy connect method for backward compatibility
Parameters
credentials
Returns
Promise<void>
Deprecated
Use constructor with ConnectorConfig instead
createDebugErrorFactory()
protectedcreateDebugErrorFactory(debugConfig?):DebugErrorFactory
Defined in: src/connectors/base-connector.ts:843
Helper method for subclasses to create debug-enabled error factory
Parameters
debugConfig?
DebugConfig
Returns
DebugErrorFactory
Inherited from
BaseConnector.createDebugErrorFactory
escapeIdentifier()
protectedescapeIdentifier(identifier):string
Defined in: src/connectors/base-connector.ts:475
Escape SQL identifiers to prevent injection
Parameters
identifier
string
Returns
string
Inherited from
BaseConnector.escapeIdentifier
executeParameterizedQuery()
protectedexecuteParameterizedQuery(sql,parameters?):Promise<QueryResultRow[]>
Defined in: src/connectors/snowflake.ts:169
Execute a parameterized SQL query using Snowflake bind variables
Parameters
sql
string
parameters?
unknown[] = []
Returns
Promise<QueryResultRow[]>
Overrides
BaseConnector.executeParameterizedQuery
executeQuery()
protectedexecuteQuery(sql):Promise<QueryResultRow[]>
Defined in: src/connectors/snowflake.ts:233
Execute a validated SQL query with security measures
Parameters
sql
string
Returns
Promise<QueryResultRow[]>
Overrides
BaseConnector.executeQuery
executeWithTimeout()
protectedexecuteWithTimeout<T>(operation,timeoutMs):Promise<T>
Defined in: src/connectors/base-connector.ts:492
Execute function with timeout protection
Type Parameters
T
T
Parameters
operation
() => Promise<T>
timeoutMs
number
Returns
Promise<T>
Inherited from
BaseConnector.executeWithTimeout
getAccount()
getAccount():
string
Defined in: src/connectors/snowflake.ts:677
Get Snowflake account name
Returns
string
getLastModified()
getLastModified(
table):Promise<Date|null>
Defined in: src/connectors/snowflake.ts:445
Get last modified timestamp for Snowflake tables
Parameters
table
string