Oracle query: design note
There is no oracle_query sensor yet. This page records why, what was tried, and what it would take, so the next person starts from the facts. The other three database kinds (postgres_query, mysql_query and mssql_query) set the bar: the same channels, a statement check, a read-only transaction, the certificate rules of the web sensors (system trust store, verify_tls, a pinned fingerprint) and a clear message for every failure.
The options
| Option | Fits the dependency rules | Verdict |
|---|---|---|
The oracle crate (ODPI-C) | No. It compiles a C library and needs the Oracle Instant Client, which is proprietary and cannot be shipped in an AGPLv3 binary or in the static musl builds. | Rejected. |
sqlx or another ORM with an Oracle driver | No such driver exists in the project's stack. | Not available. |
oracle-rs 0.1.7, a pure Rust thin client (MIT or Apache-2.0, rustls, RustCrypto) | The licence and the TLS stack fit deny.toml. | Works, but cannot meet the TLS and failure rules today. See below. |
| A thin client written here, as was done for MySQL and TDS | Fits. | Several thousand lines; see below. |
What was measured
oracle-rs 0.1.7 was tried in a scratch project (not in the repository) against Oracle 23ai Free in the lab, with an ordinary read-only account over the plain listener:
- It logs in (the 12c verifier with PBKDF2 and AES) in about 130 ms and runs
SELECTstatements: column names from the describe, three rows from a table, a constant fromdual, the version banner fromv$version. Numbers arrive as text, which is what the sensors want. SET TRANSACTION READ ONLYis accepted throughexecute; sent throughqueryit makes the driver drop the connection.- A statement the account may not run (a
DELETEon a table it can only read) does not come back asORA-01031. The driver reportsORA-00000: Server rejected the operation and closed the connectionand every later call on the connection fails withconnection not ready. A monitoring sensor needs the server's own error number and text (wrong password,ORA-12514for an unknown service, a table that is not there), because those are what an operator acts on. The other three kinds have a failure table built on exactly that. - It opens its own
TcpStreaminsideConnection::connect_with_config, and its TLS settings accept a CA file, a wallet, or "accept anything". There is no way to hand it a connected stream or a certificate verifier. That means no pinned fingerprint, no sharedverify_tlsbehaviour with the other sensors, and no use of the probe's own connect timeout and address handling. It is the same reason the MySQL and TDS clients were written by hand. - The lab listener has no TCPS port, so even a CA-file connection could not be tried against a real server.
Recommendation
Do not add a kind on top of oracle-rs as it is. It would ship a sensor whose TLS rules differ from the other three, whose most common failures read as "closed the connection", and whose encrypted path nobody has seen work.
The way forward, in order of cost:
- Ask upstream for two small changes: a constructor that takes an already connected stream (anything that is
AsyncRead + AsyncWrite), and an error path that keeps theORA-code and text when the server sends an error packet before closing. With those, the sensor is the same shape asmysql_query: our own TCP and TLS code (pin,verify_tls, SNI), the driver for the protocol, a guard module, andSET TRANSACTION READ ONLYas the first statement. If the changes are not accepted in reasonable time, carry them as a vendored patch of that one crate under its own licence notice. - A thin client of our own (TNS connect and accept, protocol and data type negotiation, the O5LOGON exchange, the execute and fetch messages). The protocol is not documented by Oracle; it would be written from the open source thin drivers, and it is a larger job than the TDS client (1,700 lines), which has a published specification. Worth doing only if upstream is a dead end.
Whichever is chosen, the sensor needs these things that the design already settles:
- Read-only. A statement check (one
SELECTorWITH, noFOR UPDATE, noINTO, strings,q'[...]'quoting, quoted names and comments read the way Oracle reads them), thenSET TRANSACTION READ ONLYas the first statement of the poll, and the advice to use an account withCREATE SESSIONandSELECTon what it reads and nothing else. A read-only transaction in Oracle refuses DML but not a call to a procedure that commits in an autonomous transaction, so the account stays the real protection, as it does on MySQL. - Channels,
expected,max_rows, the credential (user:password) as forpostgres_query. - Connecting.
host,port(1521) and a service name (FREEPDB1), not a SID. TLS means a separate TCPS listener (usually 2484), sotls: requiredselects that protocol andtls: offthe plain one; Oracle has no in-band upgrade, sooptionalwould be a second connection attempt and should be left out. - Verification. A lab listener with TCPS and a certificate from the lab CA, so the pin,
verify_tlsand the untrusted-certificate refusal can be seen against a real server, as they were for the other engines.
Until then the same checks can be made with a script sensor that calls a client the operator has installed, or with rest_json against Oracle REST Data Services.
Where the Oracle lab target is
Oracle 23ai Free is in the lab with a read-only account and a small table, for the day this is built. Live tests for it will read PROBEWARD_TEST_ORACLE_ADDR (host:port), PROBEWARD_TEST_ORACLE_SERVICE, PROBEWARD_TEST_ORACLE_USER and PROBEWARD_TEST_ORACLE_PASSWORD, and skip when they are unset.