Skip to content

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 ​

OptionFits the dependency rulesVerdict
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 driverNo 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 TDSFits.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 SELECT statements: column names from the describe, three rows from a table, a constant from dual, the version banner from v$version. Numbers arrive as text, which is what the sensors want.
  • SET TRANSACTION READ ONLY is accepted through execute; sent through query it makes the driver drop the connection.
  • A statement the account may not run (a DELETE on a table it can only read) does not come back as ORA-01031. The driver reports ORA-00000: Server rejected the operation and closed the connection and every later call on the connection fails with connection not ready. A monitoring sensor needs the server's own error number and text (wrong password, ORA-12514 for 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 TcpStream inside Connection::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 shared verify_tls behaviour 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:

  1. 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 the ORA- code and text when the server sends an error packet before closing. With those, the sensor is the same shape as mysql_query: our own TCP and TLS code (pin, verify_tls, SNI), the driver for the protocol, a guard module, and SET TRANSACTION READ ONLY as 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.
  2. 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 SELECT or WITH, no FOR UPDATE, no INTO, strings, q'[...]' quoting, quoted names and comments read the way Oracle reads them), then SET TRANSACTION READ ONLY as the first statement of the poll, and the advice to use an account with CREATE SESSION and SELECT on 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 for postgres_query.
  • Connecting. host, port (1521) and a service name (FREEPDB1), not a SID. TLS means a separate TCPS listener (usually 2484), so tls: required selects that protocol and tls: off the plain one; Oracle has no in-band upgrade, so optional would 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_tls and 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.

AGPL-3.0-only