Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .oss-scanner/threat_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The user is trusted: the SQL they type, the connections they create, the plugins

1. **The database server and the network to it.** A malicious or compromised server, or anyone on the path when TLS is not verified, controls every byte of the protocol, every result set and every error message. This includes the HTTP and REST engines and the SSH server of a tunnel.
2. **Database contents.** Cell values (text, BLOBs, JSON, images, PHP-serialized data), table, column and schema names, comments and object definitions can be written by another user of a shared database.
3. **Files the user opens or imports.** `.sql`, CSV/TSV, JSON/JSONL, XLSX, Parquet, SQLite and DuckDB files, `.tablepro` connection bundles, connection files from other apps (TablePlus, DBeaver, DataGrip, Navicat `.ncx`, Sequel Ace, Beekeeper), project folders scanned for credentials (`.env`, docker-compose, framework configs), `~/.pgpass`, `~/.ssh/config`.
3. **Files the user opens or imports.** `.sql`, CSV/TSV, JSON/JSONL, XLSX, Parquet, SQLite and DuckDB files, `.tablepro` connection bundles, connection files from other apps (TablePlus, DBeaver, DataGrip, Navicat `.ncx`, Sequel Ace, Beekeeper, DBX), project folders scanned for credentials (`.env`, docker-compose, framework configs), `~/.pgpass`, `~/.ssh/config`.
4. **Links.** `tablepro://` deep links and database URLs (`postgresql://`, `mysql://`, `mongodb+srv://` and others in `apple/TablePro/Info.plist`) opened from a browser or another app.
5. **Local MCP clients.** The Mac app runs an MCP server on loopback. A process without a valid token, or a client acting beyond its token's scopes and connection allowlist, is untrusted. So are web pages reaching that port (DNS rebinding) and the remote MCP servers TablePro connects to as a client.
6. **AI model output.** Tool calls from a model, which database contents can steer by prompt injection.
Expand Down
2 changes: 1 addition & 1 deletion core/crates/foreign-import/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ chacha20.workspace = true
flate2.workspace = true
hex.workspace = true
# The SQLite the storage crate links through sqlx, read directly because
# a Beekeeper Studio database is read once, blocking, read-only.
# a Beekeeper Studio or DBX database is read once, blocking, read-only.
libsqlite3-sys.workspace = true
plist.workspace = true
roxmltree.workspace = true
Expand Down
11 changes: 8 additions & 3 deletions core/crates/foreign-import/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub enum ForeignApp {
DataGrip,
BeekeeperStudio,
Navicat,
Dbx,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand All @@ -36,13 +37,14 @@ pub enum SavedQuerySupport {
}

impl ForeignApp {
pub const ALL: [Self; 6] = [
pub const ALL: [Self; 7] = [
Self::TablePlus,
Self::SequelAce,
Self::DBeaver,
Self::DataGrip,
Self::BeekeeperStudio,
Self::Navicat,
Self::Dbx,
];

pub fn id(self) -> &'static str {
Expand All @@ -53,6 +55,7 @@ impl ForeignApp {
Self::DataGrip => "datagrip",
Self::BeekeeperStudio => "beekeeperstudio",
Self::Navicat => "navicat",
Self::Dbx => "dbx",
}
}

Expand All @@ -68,6 +71,7 @@ impl ForeignApp {
Self::DataGrip => "DataGrip",
Self::BeekeeperStudio => "Beekeeper Studio",
Self::Navicat => "Navicat",
Self::Dbx => "DBX",
}
}

Expand All @@ -82,15 +86,15 @@ impl ForeignApp {

pub fn password_source(self) -> PasswordSource {
match self {
Self::TablePlus | Self::SequelAce | Self::DataGrip => PasswordSource::Keychain,
Self::TablePlus | Self::SequelAce | Self::DataGrip | Self::Dbx => PasswordSource::Keychain,
Self::DBeaver | Self::BeekeeperStudio | Self::Navicat => PasswordSource::AppFiles,
}
}

pub fn saved_query_support(self) -> SavedQuerySupport {
match self {
Self::TablePlus | Self::SequelAce | Self::BeekeeperStudio => SavedQuerySupport::GlobalFolder,
Self::DBeaver => SavedQuerySupport::Scripts,
Self::DBeaver | Self::Dbx => SavedQuerySupport::Scripts,
Self::DataGrip => SavedQuerySupport::Consoles,
Self::Navicat => SavedQuerySupport::NotInExport,
}
Expand Down Expand Up @@ -202,6 +206,7 @@ impl ForeignImporter {
ForeignApp::DataGrip => Box::new(apps::datagrip::DataGrip::locate(&self.dirs, keychain)),
ForeignApp::BeekeeperStudio => Box::new(apps::beekeeper::Beekeeper::locate(&self.dirs)),
ForeignApp::Navicat => Box::new(apps::navicat::Navicat::new(self.picked_file.clone())),
ForeignApp::Dbx => Box::new(apps::dbx::Dbx::locate(&self.dirs)),
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions core/crates/foreign-import/src/apps/beekeeper/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
mod encryptor;
mod locations;
mod saved_queries;
mod sqlite;

use std::collections::{BTreeMap, HashMap};
use std::path::PathBuf;

use secrecy::{ExposeSecret, SecretString};
use tokio_util::sync::CancellationToken;

use self::sqlite::{Database, Row};
use crate::app::{AppReader, check_cancel};
use crate::apps::sqlite::{Database, Row};
use crate::collect::assemble;
use crate::{
CollectedImport, ForeignApp, ForeignAppDirs, ForeignColor, ForeignConnection, ForeignConnectionRecord,
Expand Down
21 changes: 4 additions & 17 deletions core/crates/foreign-import/src/apps/beekeeper/saved_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::collections::{HashMap, HashSet};

use tokio_util::sync::CancellationToken;

use super::sqlite::Database;
use crate::app::check_cancel;
use crate::apps::sqlite::Database;
use crate::{ForeignImportError, ForeignSavedQuery, SavedQueryContent};

// Every install seeds this example, so importing it would add noise to every library.
Expand All @@ -19,7 +19,7 @@ pub(super) fn read(
limit: u64,
cancel: &CancellationToken,
) -> Result<Vec<ForeignSavedQuery>, ForeignImportError> {
let columns = column_names(db, "favorite_query");
let columns = db.columns("favorite_query");
if !columns.contains("title") || !columns.contains("text") {
return Ok(Vec::new());
}
Expand Down Expand Up @@ -70,7 +70,7 @@ pub(super) fn read(
}

pub(super) fn count(db: &Database) -> usize {
let columns = column_names(db, "favorite_query");
let columns = db.columns("favorite_query");
if !columns.contains("title") || !columns.contains("text") {
return 0;
}
Expand Down Expand Up @@ -107,7 +107,7 @@ fn where_clause(columns: &HashSet<String>, conditions: &[&str]) -> String {
}

fn read_folders(db: &Database) -> HashMap<i64, Folder> {
let columns = column_names(db, "query_folder");
let columns = db.columns("query_folder");
if !columns.contains("id") || !columns.contains("name") {
return HashMap::new();
}
Expand Down Expand Up @@ -149,19 +149,6 @@ fn folder_path(folder_id: Option<i64>, folders: &HashMap<i64, Folder>) -> Vec<St
path
}

fn column_names(db: &Database, table: &str) -> HashSet<String> {
let Some(mut statement) = db.prepare(&format!("PRAGMA table_info({table})")) else {
return HashSet::new();
};
let mut names = HashSet::new();
while let Some(row) = statement.next_row() {
if let Some(name) = row.text(1) {
names.insert(name);
}
}
names
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
16 changes: 1 addition & 15 deletions core/crates/foreign-import/src/apps/dbeaver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,21 +497,7 @@ fn color(config: &Value) -> Option<ForeignColor> {
let [r, g, b, ..] = components[..] else {
return None;
};
if r > 200 && g < 100 && b < 100 {
Some(ForeignColor::Red)
} else if r > 200 && g > 100 && g < 200 && b < 100 {
Some(ForeignColor::Orange)
} else if r > 200 && g > 200 && b < 100 {
Some(ForeignColor::Yellow)
} else if r < 100 && g > 150 && b < 100 {
Some(ForeignColor::Green)
} else if r < 100 && g < 100 && b > 200 {
Some(ForeignColor::Blue)
} else if r > 100 && g < 100 && b > 150 {
Some(ForeignColor::Purple)
} else {
None
}
super::rgb_color(r, g, b)
}

// A port is a number or a numeric string; one outside 0...65535 counts as missing.
Expand Down
Loading
Loading