HN user

sehrope

1,980 karma

Founder of JackDB, the web-based database development tool.

Website: http://www.jackdb.com/

Email: sehrope [at] jackdb [dot] com

Posts43
Comments264
View on HN
launchbylunch.com 2y ago

Postgres password encryption without leaking credentials

sehrope
4pts0
launchbylunch.com 8y ago

How I Write SQL, Part 1: Naming Conventions (2014)

sehrope
164pts78
nodesecurity.io 8y ago

Remote code execution vulnerability in node-postgres

sehrope
3pts0
forums.aws.amazon.com 11y ago

Amazon RDS: Action Required for SSL Users by 23 Mar 2015

sehrope
4pts0
www.theregister.co.uk 11y ago

Misfortune Cookie crumbles router security: '12 MILLION+' in hijack risk

sehrope
5pts0
arstechnica.com 11y ago

AT&T demands clarity: Are warrants needed for customer cell-site data?

sehrope
2pts0
arstechnica.com 11y ago

Verizon: ISPs will sue unless government adopts weaker net neutrality rules

sehrope
2pts0
arstechnica.com 11y ago

TV monitoring service is fair use, judge rules

sehrope
131pts34
gizmodo.com 11y ago

A Mobius Strip Track Makes Magnet Hovercrafts Even Cooler

sehrope
2pts0
www.theregister.co.uk 11y ago

It's official: You can now legally carrier-unlock your mobile in the US

sehrope
3pts0
launchbylunch.com 12y ago

How I Write SQL, Part 1: Naming Conventions

sehrope
4pts0
arstechnica.com 12y ago

Netflix slow on Verizon or Comcast? A VPN might speed up that video

sehrope
1pts0
drpeering.net 12y ago

The Art of Peering: The Peering Playbook

sehrope
58pts1
arstechnica.com 12y ago

Payments experts assure Senate that swipe-and-sign cards will disappear in 2015

sehrope
1pts0
launchbylunch.com 12y ago

AWS Tips, Tricks, and Techniques

sehrope
295pts56
launchbylunch.com 12y ago

My blog's tech stack: Pelican powered, Dokku deployed

sehrope
1pts0
launchbylunch.com 12y ago

Encrypting Docker containers on a Virtual Server

sehrope
2pts0
blog.mathieu-leplatre.info 12y ago

Publish your Pelican blog on Github pages via Travis-CI

sehrope
1pts0
launchbylunch.com 12y ago

How to set up a private PaaS with Dokku on DigitalOcean

sehrope
1pts0
www.jackdb.com 12y ago

JackDB – Query and analyze any database in the cloud, right in your web browser

sehrope
30pts17
www.washingtonpost.com 12y ago

Senate poised to limit filibusters in party-line vote

sehrope
1pts0
www.usatoday.com 12y ago

TSA union calls for armed guards at every checkpoint

sehrope
38pts83
blog.jackdb.com 12y ago

PostgreSQL Execution Plans In JackDB

sehrope
1pts0
blog.jackdb.com 12y ago

How to import CSV files with JackDB

sehrope
3pts0
www.nytimes.com 12y ago

Appeals Court Upholds Ruling That Halted NYC's Large-Soda Ban

sehrope
1pts0
blog.jackdb.com 13y ago

Adding Heroku Data Sources To JackDB With OAuth

sehrope
1pts0
www.postgresopen.org 13y ago

Postgres Open 2013 – List Of Talks

sehrope
35pts3
blog.jackdb.com 13y ago

Previewing BLOB columns in JackDB

sehrope
1pts0
blog.jackdb.com 13y ago

How to add Heroku data sources to JackDB

sehrope
1pts0
blog.jackdb.com 13y ago

Auto Importing SSL Certificates Into JackDB

sehrope
1pts0

The intended usage is that the client tells the server, "I want to load data from a file /path/to/data.txt on my local filesystem" in a SQL command. As part of the protocol for executing the query the server sends a message to the client to request the contents of /path/to/data.txt. Unfortunately client's don't validate the file request and will send any file (ex: /path/to/secrets.txt) even if there was no legit data request in their command.

This has been an issue with MySQL client drivers for years. I found and fixed the same issue in MariaDB Connector/J (JDBC driver (wire compatible with MySQL databases) in 2015. It rejects LOCAL DATA requests from the server unless the client app preregistered an InputStream (Java interface for generic stream of bytes) as data for the command being executing.

This is one of the many many reasons I love open source database drivers. I was able to find and fix this issue only because I could see the source code. Similar "features" in proprietary databases could go unnoticed for years and even when discovered may not have feature flags to disable them.

PostgreSQL 11 introduces SQL stored procedures that allow users to use embedded transactions (i.e. BEGIN, COMMIT/ROLLBACK) within a procedure. Procedures can be created using the CREATE PROCEDURE command and executed using the CALL command.

I'm pretty sure this is going to be my favorite feature in v11 as it will facilitate conditional DDL for the few remaining things at aren't already allowed in transactions, in particular add values to enums.

Prior to v11 you could create new enums in a transaction but could not add values to an existing one. IIUC how this v11 feature works, you could now have a stored procedure check the current value list of the enum and decide to issue an ALTER TYPE ... ADD VALUE ... at runtime, optionally discarding any concurrency error. All of that could run from a SQL command, no external program needed.

Prior to PostgreSQL 11, one such feature was using the ALTER TABLE .. ADD COLUMN command where the newly created column had a DEFAULT value that was not NULL. Prior to PostgreSQL 11, when executing aforementioned statement, PostgreSQL would rewrite the whole table, which on larger tables in active systems could cause a cascade of problems. PostgreSQL 11 removes the need to rewrite the table in most cases, and as such running ALTER TABLE .. ADD COLUMN .. DEFAULT .. will execute extremely quickly.

... and this is a close second favorite. Having NOT NULL constraints on columns makes schemas much more pleasant to work with, but for schema migrations that means requiring DEFAULT clause to populate existing data. While there are ways to slowly migrate to a NOT NULL / DEFAULT config for a new column (e.g. add column without constraint, migrate data piecemeal, likely in batches of N records, then enable constraint), having it for free in core without rewriting the table at all is simply awesome.

UUIDs are fine too. What matters is how they're generated.

If you're generating v4 UUIDs server side using the "uuid" NPM module then you're fine as internally it's using crypto.randomBytes(...)[1] with an almost 16-byte random string (UUIDs are 16-bytes but a proper v4 UUID has to override some of the bits to conform to the spec[2]).

If you're rolling your own UUID function or generating them client side then they may not be as random as you think. For example the same uuid NPM module silently uses Math.random()[3] on the client side if it can't find a better alternative. It's fine for something purely local to the one browser but I wouldn't rely on it being unique globally.

[1] https://github.com/kelektiv/node-uuid/blob/17d443f7d8cfb65a7...

[2] https://github.com/kelektiv/node-uuid/blob/17d443f7d8cfb65a7...

[3] https://github.com/kelektiv/node-uuid/blob/17d443f7d8cfb65a7...

I've used WAL-E (the predecessor of this) for backing up Postgres's DB for years and it's been a very pleasant experience. From what I've read so far this looks like it's superior in every way. Lower resource usage, faster operation, and the switch to Go for WAL-G (v.s. Python for WAL-E) means no more mucking with Python versions either.

Great job to everybody that's working on this. I'm looking forward to trying it out.

Finally!

Having dealt with many database drivers over the years, I can say first hand that closed source drivers are the bane of my existence. The only thing worse than running into a deep-in-the-stack bug in a database driver is one that you can't correct, let alone debug properly.

Regardless of your views on closed source software on the server side of things, it's a disservice to your customers to not have open source client side drivers. The secret sauce is always on the server side so it doesn't buy you anything. At best there's (very poor) argument for security through obscurity or you're doing something silly like hiding server side features behind client side feature flags.

Plus the more tech savvy of your users will directly contribute back to improve the driver. This is both for fixing existing bugs and adding features to support existing database server features. In this particular case, I've got a laundry list of things I'd like corrected / added / improved in the SQL Server JDBC driver. Had it been open sourced a few years back, I would have already done them myself.

Unless there's a legal restriction for not doing so, like say not owning the original source, there's no good reason not to open source the client side of things.

For me 600 iterations takes about 3ms (I guess my laptop is a bit faster). A decent range to shoot for is .5-1 sec.

Test program:

    crypto = require 'crypto'

    password = 'testing'
    len = 128
    salt = crypto.randomBytes(len)

    iters = Number(process.argv[2] || 600)

    console.log 'Testing iters=%s', iters
    for i in [1..10]
      start = Date.now()
      crypto.pbkdf2Sync password, salt, iters, len
      elapsed = Date.now() - start
      console.log '   Test #%s - %s ms', i, elapsed
Output:
      $ coffee pbkdf2-test.coffee 100000
      Testing iters=100000
         Test #1 - 497 ms
         Test #2 - 510 ms
         Test #3 - 496 ms
         Test #4 - 525 ms
         Test #5 - 510 ms
         Test #6 - 493 ms
         Test #7 - 521 ms
         Test #8 - 518 ms
         Test #9 - 510 ms
         Test #10 - 498 ms

      $ coffee pbkdf2-test.coffee 10000
      Testing iters=10000
         Test #1 - 54 ms
         Test #2 - 50 ms
         Test #3 - 50 ms
         Test #4 - 55 ms
         Test #5 - 51 ms
         Test #6 - 52 ms
         Test #7 - 50 ms
         Test #8 - 49 ms
         Test #9 - 51 ms
         Test #10 - 50 ms

      $ coffee pbkdf2-test.coffee 600
      Testing iters=600
         Test #1 - 3 ms
         Test #2 - 3 ms
         Test #3 - 3 ms
         Test #4 - 3 ms
         Test #5 - 3 ms
         Test #6 - 4 ms
         Test #7 - 3 ms
         Test #8 - 4 ms
         Test #9 - 3 ms
         Test #10 - 3 ms

From the link:

    ITERATIONS = 600
    ...
    crypto.pbkdf2 pwd, salt, ITERATIONS, LEN, (err, hash) ->

That's way too small for the number of iterations. Something like 100K would be a better choice.

Alternatively here's a version that uses bcrypt:

    bcrypt = require 'bcrypt'
    rounds = Number(process.env.BCRYPT_ROUNDS || 12)

    module.exports =
      hash: (password, cb) ->
        bcrypt.hash password, rounds, cb

      compare: (password, hashedPassword, cb) ->
        bcrypt.compare password, hashedPassword, cb

... and if streams become a better and better option as response sizes get larger and larger. The streams syntax is nicer looking in any case.

fs.readFile(...) reads the entire contents of the file into memory. For small files that may be acceptable but if you're dealing with anything that could be large it's not going to be very pleasant or even work properly.

I just tried it out on my laptop for a 100MB and a 1GB file. For a 100MB file using streams is about 25% slower. However the sync method failed for the 1GB file:

    Style            100MB       1GB
    =====            =====       ===
    fs.readFileSync  .176s    <failed>
    streams/pipe     .234s      1.25s
IO.js, a Node fork 12 years ago

Any background on who's doing this or what the motivation is?

The linked site doesn't have much content besides a link to the GitHub repo.

EDIT: Even though it's not explicitly listed in the README or contributor list, the commit history does show a bit of detail: https://github.com/iojs/io.js/commits/v0.12

Java Doesn’t Suck 12 years ago

If your app needs a relational database then use an in-memory db like hsql or cloud services like Heroku Postgres, RDS, Redis Labs, etc. However one risk with most in-memory databases is that they differ from what is used in production. JPA / Hibernate try to hide this but sometimes bugs crop up due to subtle differences. So it is best to mimic the production services for developers even down to the version of the database.

The idea that you can develop locally or test against a different type of database then what you are (or will be) using in production is silly. I don't just think it "sometimes" is a bad idea, I reject it outright. You should always be using the exact same database (type and version).

For cloud deployments most XaaS providers have cheap or free dev tiers. For local development it's easy to use VMs. For any project that requires external resources (Postgres, Redis, RabbitMQ, etc) I have a VM that gets spun up via Vagrant[1]. Just "vagrant up" and all external resources required by the app should be available.

So first… Use a build tool. It doesn’t matter if you choose Ant + Ivy, Maven, Gradle, or sbt. Just pick one and use it to automatically pull your dependencies from Maven Central or your own Artifactory / Nexus server. With WebJars you can even manage your JavaScript and CSS library dependencies. Then get fancy by automatically denying SCM check-ins that include Jar files.

Though I agree that it's a good idea to have dependencies externalized, it's not always possible. Some libraries (ex: third party JARs) are not available in public Maven repos and not everyone has a private one setup. In those situations it's fine to check in the JAR into the project itself.

I like the approach outlined by Heroku for dealing with unmanaged dependencies[2]. You declare them normally in your pom.xml but also include the path to a local directory (checked into SCM) with the JAR files. Anybody that clones your repo should be able to build the project with no manual steps. Works great!

[1] https://www.vagrantup.com/

[2] https://devcenter.heroku.com/articles/local-maven-dependenci...

LATERAL is awesome. It makes a lot of queries that required sub-select joins much simpler to write and later read.

It's also great for set returning functions. Even cooler, you don't need to explicitly specify the LATERAL keyword. The query planner will add it for you automatically:

    -- NOTE: WITH clause is just to fake a table with data:
    WITH foo AS (
      SELECT 'a' AS name
           , 2 AS quantity
      UNION ALL
      SELECT 'b' AS name
           , 4 AS quantity)
    SELECT t.*
         , x
    FROM foo t
      -- No need to say "LATERAL" here as it's added automatically
      , generate_series(1,quantity) x;
    
    name | quantity | x
    ------+----------+---
    a    |        2 | 1
    a    |        2 | 2
    b    |        4 | 1
    b    |        4 | 2
    b    |        4 | 3
    b    |        4 | 4
    (6 rows)

Most Postgres clients have issues connecting to Amazon Redshift. The wire protocol is the same so basic interactions (ex: connect via psql and run a SELECT) usually works but things get hairy when you start doing more complicated things or even just querying the data dictionary (the basic information_schema is there but Redshift has it's own tables for it's specific features).

My company[1] makes a database client that runs in your web browser that has explicit support for Redshift (as well as Postgres, MySQL, and more). I encourage you to check it out.

[1] https://www.jackdb.com/

In this trial, XFINITY Internet Economy Plus customers can choose to enroll in the Flexible-Data Option to receive a $5.00 credit on their monthly bill and reduce their data usage plan from 300 GB to 5 GB. If customers choose this option and use more than 5 GB of data in any given month, they will not receive the $5.00 credit and will be charged an additional $1.00 for each gigabyte of data used over the 5 GB included in the Flexible-Data Option.

What informed consumer would agree to this?!

Streaming Netflix uses about 1GB/hour for "good" quality streams and 2+GB/hour for HD streams. That would make watching an hour a night come out to $30-60/month of bandwidth charges. Multiply accordingly if you watch more or have multiple people streaming simultaneously. Oh and the way it's worded it sounds like you lose the $5 discount if you go over 5GB.

I can see this leading to some serious bill shock for anybody that signs up.

Oracle supported both full refresh and incremental refresh as of at least 10 years ago (maybe longer).

Fast refresh requires creating "MATERIALIZED VIEW LOGS" on the source table(s) and covers most (but not all) aggregations/groupings in the mview SQL. Once it's setup, DML to the source tables gets logged to the mview logs and a "fast" refresh of the mview uses it to incrementally update the mview's data.

> Seemed like a good idea until it dawned on me that this means the passwords are stored as plaintext.

There are several ways this can be done without that.

Easiest is if they store the date of the last password change or otherwise know you haven't changed it. If it's old enough, double the plaintext before handing it to the hashing function.

Not quite. What you'd need to do is halve the user's entered password if it's older than the cutoff date. If the user enters "foobarfoobar" then you'd halve it to "foobar" before hashing and comparing it to what's stored.

If you only have the old hashed password stored then you don't have the hash of the doubled password, nor can you can infer it.

This whole approach is silly of course. They should just force everybody to reset their passwords.

The old prototype machine had our AWS API access key and secret key. Once the hacker gained access to the keys, he created an IAM user, and generated a key-pair.

Ouch! This is why you must practice the principle of least privilege when provisioning access keys, especially ones that can control your entire infrastructure.

He was then able to run an instance inside our AWS account using these credentials, and mount one of our backup disks.

Good security practices are like an onion ... it's got many layers and will most likely make you cry.

This is why you should be encrypting your backups. The backup program doesn't even need to be able to read the backups it creates, it only needs to to be able to write them (i.e. the public half of the key).

If you're thinking, "Why does that matter? It can already read the plain-text data it's backing up!" then you're not thinking about history or multiple servers. Each may be able to read the current state of its own file system, but if they only have the public half, they can't read the historical state or each other's backups. The damage would be limited to a single server and only what's live on it at that moment.

We were able to verify the actions of the hacker using AWS CloudTrail, which confirmed that no other services were compromised, no other machines were booted, and our AMIs and other data stores were not copied.

CloudTrail is awesome and if you're on AWS you really should enable it. It costs peanuts compared to what it provides. In cases like this, where the attacker takes over your entire infrastructure, it may be the only log you have of what happened.

This is pretty neat. I'm a big fan of SQL in general and being able to query system stats like this feels pretty natural to me.

A long time back I created something similar to this atop Oracle[1]. It used a Java function calling out to system functions to get similar data sets (I/O usage, memory usage, etc). It was definitely a hack, but a really pleasant one to use.

Be cool to see an foreign data wrapper for PostgreSQL[2] that exposes similar functionality. I'm guessing it'd be pretty easy to put together as you'd only need to expose the data sets themselves as set returning functions. PostgreSQL would handle the rest. Though I guess that would limit it's usefulness to servers that have PG already installed. Having it be separate like this let's you drop it on any server (looks like it's cross platform too!).

[1]: I don't remember exactly when but I think 10g had just been released.

[2] http://www.postgresql.org/docs/9.3/static/postgres-fdw.html

Copywrong 12 years ago

An interesting solution I've heard[1] to reform both copyright (and possibly patent) law is to require compounding annual fees to maintain them. For example if someone writes a new song or book, we could have a short "free" copyright period. After that, creator (or more accurately, the rights holder) would need to pay an annual fee to maintain their copyright. The fee would increase by some percentage each year.

If the value of the work is greater than the fee, then it'd be in the interests of the rights holder to pay the fee and maintain the copyright, for example to be able to license it out to others. If it's not, then the copyright would expire and the work would enter the public domain.

A high enough interest rate for the compounding would ensure that everything is eventually in the public domain. For works that are repeatedly extended, say Mickey Mouse, the public will receive the fees collected for each of the extensions until it enters the public domain.

This also has the interesting effect of incentivizing the creation of new works as there wouldn't be any fees associated with them for the initial term.

There's obviously a lot more details to handle such as having a central registry, inflation adjustments, differentiating between new works and derived works, and how to handle works created prior to the introduction of a system like this. Still I think it's an interesting proposal.

[1]: I don't remember where exactly but probably here on HN.

$500/month for a service like this?

$500/mo sounds like peanuts for what a service like this provides. For a business that would use this type of information (e.g. TV shows like Daily Show or Colbert or a political campaign) it's both worth more and cheaper than doing it in house. The power bill alone for all those TV-tuners/DVRs would be more than that!

I'm surprised that it's not more expensive.

Chattanooga has the largest high-speed internet service in the US, offering customers access to speeds of 1 gigabit per second – about 50 times faster than the US average. The service, provided by municipally owned EPB, has sparked a tech boom in the city and attracted international attention. EPB is now petitioning the FCC to expand its territory. Comcast and others have previously sued unsuccessfully to stop EPB’s fibre optic roll out.

I did a quick search to see pricing for EPB's internet service and wow is it cheap[1]. The two plans listed on the site are 100 Mbps for $57.99/mo or 1Gpbs $69.99/mo. Oh and both plans are symmetric so you get that for upload as well.

I don't know of any city where the local cable co offers anything like that, let alone at those price points. No wonder they want to block this through legislation; competing in the market would not be pleasant for them.

[1] https://epbfi.com/internet/

Including typos in the spam messages falls in this same category. If seeing typos in an "official communication" triggers your alarm bells then you probably would not fall for whatever scamola it's a part of. It'd be in their interests to get you to drop off early.

Heroku needs to open source the testing it has used to claim 3X performance.

The bottom of the bar chart says: Database performance was measured using pg bench with 150 concurrent clients performing read-only transactions.

pgbench[1] is a performance benchmarking tool that is part of PostgreSQL itself. It ships alongside the rest of the PostgreSQL binaries and is open source just like the rest of PostgreSQL.

I think this line from the article is interesting:

In addition to Heroku Postgres DbX we are launching new database plans with double the memory and speed improvements of up to 3x at the same price as our current plan lineup. These plans feature an upgraded and re-engineered infrastructure to drastically improve their memory and speed.

I wonder if the bulk of the price/performance gains are from switching to newer instance types on AWS and/or switching the underlying storage from magnetic disks to the new SSD EBS volumes[2].

[1] http://www.postgresql.org/docs/devel/static/pgbench.html

[2] http://aws.amazon.com/about-aws/whats-new/2014/06/16/introdu...

NPR One 12 years ago

This is all well and good, but why does everyone need to have their own damn app?

I can't comment on this new app yet but I'm a near daily user of the regular NPR app (which I think is officially called "NPR news"). It's way better than any generic radio app I've tried.

Besides listening to the individual local stations, you can also get the latest news (the ~4-minute hourly blurb), can create playlists of entire shows (without the interludes, i.e. just the content), and built-in news articles (for reading, not listening). I've even used the local NPR station finder to help me tune an analog radio when in a new city where I'm not familiar with the local stations.

It'd take quite a bit of agreement on content licensing and data formats to have anything like that be as usable as the NPR app across multiple content providers.

Seriously - why does everyone assume that if I want to listen to e.g. NPR, I only want to listen to NPR?

Well some of us do :D

So if your Twitter password happens to be the same as your ATT password, you're out of luck.

Why would you have both passwords be the same? That makes no sense. All passwords should be different.

I only use two factor authentication if I can add it to my Authenticator app and save the code/QR code somewhere offline. Everything else is just too complex to be secure.

TOTP based two-factor auth (e.g. Google Authenticator) is my preferred method as well though I'll still set up an alternative method if it's not available. For example Namecheap offers 2FA via SMS. While not preferred, it's better than nothing.