Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with upstream go-ora #3

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "CodeQL"

on:
push:
branches:
- teleport
pull_request:
branches:
- teleport

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
11 changes: 11 additions & 0 deletions .github/workflows/dependency-review.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Dependency Review

on:
pull_request:

jobs:
dependency-review:
if: ${{ !startsWith(github.head_ref, 'dependabot/') }}
uses: gravitational/shared-workflows/.github/workflows/dependency-review.yaml@main
permissions:
contents: read
2 changes: 2 additions & 0 deletions v2/configurations/session_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package configurations

import (
"context"
"crypto/tls"
"fmt"
"net"
"strings"
Expand All @@ -22,6 +23,7 @@ type SessionInfo struct {
Protocol string
SSL bool
SSLVerify bool
TLSConfig *tls.Config
Dialer DialerContext
}

Expand Down
9 changes: 9 additions & 0 deletions v2/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package go_ora

import (
"context"
"crypto/tls"
"database/sql"
"database/sql/driver"
"encoding/binary"
Expand Down Expand Up @@ -118,6 +119,7 @@ type OracleConnector struct {
drv *OracleDriver
connectString string
dialer configurations.DialerContext
tlsConfig *tls.Config
}

func NewConnector(connString string) driver.Connector {
Expand All @@ -144,6 +146,9 @@ func (connector *OracleConnector) Connect(ctx context.Context) (driver.Conn, err
if conn.connOption.Dialer == nil {
conn.connOption.Dialer = connector.dialer
}
if conn.connOption.TLSConfig == nil {
conn.connOption.TLSConfig = connector.tlsConfig
}
err = conn.OpenWithContext(ctx)
if err != nil {
return nil, err
Expand All @@ -163,6 +168,10 @@ func (connector *OracleConnector) Dialer(dialer configurations.DialerContext) {
connector.dialer = dialer
}

func (connector *OracleConnector) WithTLSConfig(config *tls.Config) {
connector.tlsConfig = config
}

// Open return a new open connection
func (driver *OracleDriver) Open(name string) (driver.Conn, error) {
conn, err := NewConnection(name, driver.connOption)
Expand Down
9 changes: 8 additions & 1 deletion v2/network/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,20 @@ func (session *Session) LoadSSLData(certs, keys, certRequests [][]byte) error {
// used to create sslConn object
func (session *Session) negotiate() {
connOption := session.Context.connConfig
host := connOption.GetActiveServer(false)

if tlsConfig := connOption.TLSConfig; tlsConfig != nil {
tlsConfig.ServerName = host.Addr
session.sslConn = tls.Client(session.conn, tlsConfig)
return
}

if session.SSL.roots == nil && len(session.SSL.Certificates) > 0 {
session.SSL.roots = x509.NewCertPool()
for _, cert := range session.SSL.Certificates {
session.SSL.roots.AddCert(cert)
}
}
host := connOption.GetActiveServer(false)
config := &tls.Config{
ServerName: host.Addr,
}
Expand Down
Loading