Commit Graph

76 Commits

Author SHA1 Message Date
Puru Gupta
fcef6e5cb2 server: http ip blocklist (closes #2449)
## Description

This PR is in reference to #2449 (support IP blacklisting for multitenant)

*RFC Update: Add support for IPv6 blocking*

### Solution and Design

Using [http-client-restricted](https://hackage.haskell.org/package/http-client-restricted) package, we're creating the HTTP manager with restricting capabilities. The IPs can be supplied from the CLI arguments as `--ipv4BlocklistCidrs cidr1, cidr2...` or `--disableDefaultIPv4Blocklist` for a default IP list. The new manager will block all requests to the provided CIDRs.

We are extracting the error message string to show the end-user that given IP is blocked from being set as a webhook. There are 2 ways to extract the error message "connection to IP address is blocked". Given below are the responses from event trigger to a blocked IP for these implementations:
- 6d74fde316f61e246c861befcca5059d33972fa7 - We return the error message string as a HTTPErr(HOther) from `Hasura/Eventing/HTTP.hs`.
```
{
    "data": {
        "message": "blocked connection to private IP address "
    },
    "version": "2",
    "type": "client_error"
}
```

- 88e17456345cbb449a5ecd4877c84c9f319dbc25 - We case match on HTTPExceptionContent for InternaException in `Hasura/HTTP.hs` and extract the error message string from it. (this is implemented as it handles all the cases where pro engine makes webhook requests)
```
{
  "data": {
    "message": {
      "type": "http_exception",
      "message": "blocked connection to private IP address ",
      "request": {
        "secure": false,
        "path": "/webhook",
        "responseTimeout": "ResponseTimeoutMicro 60000000",
        "queryString": "",
        "method": "POST",
        "requestHeaders": {
          "Content-Type": "application/json",
          "X-B3-ParentSpanId": "5ae6573edb2a6b36",
          "X-B3-TraceId": "29ea7bd6de6ebb8f",
          "X-B3-SpanId": "303137d9f1d4f341",
          "User-Agent": "hasura-graphql-engine/cerebushttp-ip-blacklist-a793a0e41-dirty"
        },
        "host": "139.59.90.109",
        "port": 8000
      }
    }
  },
  "version": "2",
  "type": "client_error"
}
```

### Steps to test and verify
The restricted IPs can be used as webhooks in event triggers, and hasura will return an error message in reponse.

### Limitations, known bugs & workarounds
- The `http-client-restricted` has a needlessly complex interface, and puts effort into implementing proxy support which we don't want, so we've inlined a stripped down version.
- Performance constraint: As the blocking is checked for each request, if a long list of blocked CIDRs is supplied, iterating through all of them is not what we would prefer. Using trie is suggested to overcome this. (Added to RFC)
- Calls to Lux endpoints are inconsistent: We use either the http manager from the ProServeCtx which is unrestricted, or the http manager from the ServeCtx which is restricted (the latter through the instances for MonadMetadataApiAuthorization and UserAuthentication). (The failure scenario here would be: cloud sets PRO_ENDPOINT to something that resolves to an internal address, and then restricted requests to those endpoints fail, causing auth to fail on user requests. This is about HTTP requests to lux auth endpoints.)

## Changelog

-  `CHANGELOG.md` is updated with user-facing content relevant to this PR.

## Affected components

-  Server
-  Tests

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3186
Co-authored-by: Robert <132113+robx@users.noreply.github.com>
GitOrigin-RevId: 5bd2de2d028bc416b02c99e996c7bebce56fb1e7
2022-02-25 13:30:57 +00:00
paritosh-08
bc74046ab2 server: case insensitive lookup in session variable
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3663
GitOrigin-RevId: b36666d8849a23dad209f9921f140390c2b57496
2022-02-24 13:08:35 +00:00
Solomon
6c7820caa0 Bumps Kriti Version
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3625
GitOrigin-RevId: a453254ac89b470a56189e6178b2a00cf628fe63
2022-02-15 22:32:38 +00:00
Gil Mizrahi
476eb5fe2b update odbc to 0.2.6
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3647
GitOrigin-RevId: 82fb189c2bff9dce1c1b2e8e9dd2be4d9bc7f527
2022-02-14 10:43:08 +00:00
Rakesh Emmadi
793aede022 server/mssql: improve database exception handling and better API errors
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3487
GitOrigin-RevId: d3f696072e8290b45c2f81509ce31cb5c13a4aef
2022-02-07 14:12:55 +00:00
Evie Ciobanu
9ddb3ae106 server: fix building kriti-lang by using a branch fix
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3432
Co-authored-by: Robert <132113+robx@users.noreply.github.com>
GitOrigin-RevId: c067eee0a7dba32b79420ab078b2233d4fbfda75
2022-01-21 10:29:51 +00:00
Rakesh Emmadi
5419236afd server/mssql: update odbc to 0.2.5
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3386
GitOrigin-RevId: fe508c34f548d1a5653b1d4f484277d5b4e41167
2022-01-19 06:58:30 +00:00
Solomon
4b792abdcc Feature/webhook response transforms
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3074
Co-authored-by: David Overton <7734777+dmoverton@users.noreply.github.com>
Co-authored-by: Lyndon Maydwell <92299+sordina@users.noreply.github.com>
Co-authored-by: Tirumarai Selvan <8663570+tirumaraiselvan@users.noreply.github.com>
GitOrigin-RevId: 006c5c9b71cdca1c2f47962230e6189e09557fab
2022-01-19 04:47:36 +00:00
Rakesh Emmadi
42a2787290 server/mssql: update odbc git reference to the commit which has error message fix
## Description

I come across a flaky test due to inconsistent error messages from the odbc lib we use for MSSQL database interactions.
```
cabal new-run -- test:graphql-engine-tests mssql
Up to date

Database.MSSQL.TransactionSpec
  runTx
    runs command in a transaction
    commits a successful transaction, returning a single field
    commits a successful transaction, returning multiple fields
    an unsuccesful transaction, expecting Int
    a successfull query expecting multiple rows
    an unsuccesful transaction; expecting single row
    displays the SQL Server error on an unsuccessful transaction FAILED [1]
    rolls back an unsuccessful transaction

Failures:

  src-test/Database/MSSQL/TransactionSpec.hs:60:15:
  1) Database.MSSQL.TransactionSpec.runTx displays the SQL Server error on an unsuccessful transaction
       expected: UnsuccessfulReturnCode "odbc_SQLExecDirectW" (-1) "[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type.[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type."
        but got: UnsuccessfulReturnCode "odbc_SQLExecDirectW" (-1) "[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type.[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The definition for column 'INVALID_SYNTAX' must include a data type.\DEL"

  To rerun use: --match "/Database.MSSQL.TransactionSpec/runTx/displays the SQL Server error on an unsuccessful transaction/"

Randomized with seed 1101559172

Finished in 0.2140 seconds
8 examples, 1 failure
```
From above, we got a error message with `\DEL` appended. It is also driving the tests to fail in the CI on random PRs.

We brought this into notice of "fpco", the authors of the library and they got us a [quick fix](https://github.com/fpco/odbc/pull/43), which also improves the errors by removing the redundancy of the error message.

In this PR
- We update the `odbc` library git reference to fc5b592a60
- Update the error messages in tests to conform with improved error messages from `odbc`

## Related issues
Closes https://github.com/hasura/graphql-engine-mono/issues/3340

## Changelog

-  `CHANGELOG.md` is updated with user-facing content relevant to this PR.

## Affected components
-  server
-  tests

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3345
GitOrigin-RevId: a5694e8afb58b5ad71b9c9635a80dea1ec449f51
2022-01-13 11:15:01 +00:00
awjchen
1f196ea2fc server: update ekg forks
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3213
GitOrigin-RevId: 5ccc59012784542e7eac30e0277482cc85e8abaa
2021-12-27 17:01:46 +00:00
kodiakhq[bot]
020198969f ci: fix up pro build scripts, optimize cabal/ghc build flags
Before these changes:

**pro build:** 52min
**oss build**: 62min

After:

**pro build:** 25min
**oss build**: 23min

This decreases overall CI wall-clock time from 1:50:00 to 1:15:00.

Despite bumping the instance size for OSS builds this should (back-of-envelope) **_cut_ CI costs** for haskell build stuff by ~33%

Future work will:

- cache library dependency build products: saves further ~8 min (build and wallclock)
- use the oss lib build products in pro as well: saves further ~5min server time (i.e. saves money for same build time)
- maybe cache the rest of `dist-newstyle`: savings depend on the diff (at most 4.5 min; is this even worthwhile?)

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2937
GitOrigin-RevId: a1faceaf1adfc1701e634a887f2cdabacab5cddd
2021-11-24 08:20:14 +00:00
Solomon
2bbc3e5d26 Bumps the Kriti Pin to 0.2.2
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2891
Co-authored-by: Lyndon Maydwell <92299+sordina@users.noreply.github.com>
GitOrigin-RevId: 2517fc3efdf6708177d6163db023c67a7f7e2ec5
2021-11-22 12:23:23 +00:00
Gil Mizrahi
0e65932355 server/mssql support delete mutations (close hasura/graphql-engine#7626)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2691
Co-authored-by: Abby Sassel <3883855+sassela@users.noreply.github.com>
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com>
GitOrigin-RevId: 8b66cc30e8e036ee56a5267c1d2f308155951ae9
2021-11-19 17:06:01 +00:00
jkachmar
576b07db28 ci,server: upgrades to GHC 8.10.7 and reworks server builder image
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2727
Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com>
Co-authored-by: Swann Moreau <62569634+evertedsphere@users.noreply.github.com>
Co-authored-by: Robert <132113+robx@users.noreply.github.com>
GitOrigin-RevId: 0779ab7755fd4bdb7ed1551629b2c01d99c5ccf0
2021-11-15 13:22:39 +00:00
Solomon Bothwell
256b59f030 Updates kriti pin to 0.2.1
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2697
GitOrigin-RevId: 89705a3cc5a67c28cbf8d120df190fc4e42c24ff
2021-10-28 00:26:30 +00:00
hasura-bot
557e71ecc1 Upgrade the graphql parser
GITHUB_PR_NUMBER: 7673
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/7673

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2558
Co-authored-by: José Lorenzo Rodríguez <37621+lorenzo@users.noreply.github.com>
GitOrigin-RevId: f164d2b9694ea4e8a8d5f113021dc9568bb14661
2021-10-22 11:54:19 +00:00
Brandon Simmons
a10ec5c8d8 server: tune ghc unfolding/specialization flags for performance (closes #2610)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2629
GitOrigin-RevId: acb22a595cae672bdf5a0303094fb28fc5afcfb3
2021-10-20 16:14:54 +00:00
Lyndon Maydwell
1ae8bf00f7 Update Kriti to support field lookup by string literal in webhook transformations
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2482
GitOrigin-RevId: 4f5ea1c3b7989a17368ab995c6a45c7135253ba0
2021-10-01 06:24:06 +00:00
Robert
fbd1262ea6 server: operation timeout with postgres cancelling
### Description

This PR implements operation timeouts, as specced in #1232.

RFC: [rfcs/operation-timeout-api-limits.md](c025a90fe9/rfcs/operation-timeout-api-limits.md)

There's still some things to be done (tests and docs most notably), but apart from that it can
be reviewed. I'd still appreciate feedback on the RFC!

TODO:
- [x] break out the `ApiLimits` refactoring into a separate PR: #2103
- [x] finish the `pg-client-hs` PR: https://github.com/hasura/pg-client-hs/pull/39
- [x] remove configurability, after testing, prior to merging
- [ ] tests: #2390 has some tests that I've run locally to confirm things work on a fundamental level
- [x] changelog
- [x] documentation
- [x] fill in the detailed PR checklist

### Changelog

- [x] `CHANGELOG.md` is updated with user-facing content relevant to this PR. If no changelog is required, then add the `no-changelog-required` label.

### Affected components

- [x] Server
- [ ] Console
- [ ] CLI
- [x] Docs
- [ ] Tests

### Related Issues

Product spec: #1232.

### Solution and Design

Compare `rfcs/operation-timeout-api-limits.md`.

### Steps to test and verify

Configure operation timeouts, e.g. by posting

```
{
  "type": "set_api_limits",
  "args": {
    "operation_timeout": {
      "global": 3
    }
  }
}
```

to `v1/metadata` to set an operation timeout of 3s. Then verify that
1. non-admin queries that take longer than 3s time out with a nice error message
2. that those queries return after ~3s (at least for postgres)
3. also that everything else still works as usual

### Limitations, known bugs & workarounds
- while this will cause slow queries against any backends to fail, it's only verified to actually interrupt queries against postgres
- this will only successfully short-cut (cancel) queries to postgres if the database server is responsive

#### Catalog upgrade
Does this PR change Hasura Catalog version?
- [x] No

#### Metadata

Does this PR add a new Metadata feature?
- [x] Yes
  - Does `run_sql` auto manages the new metadata through schema diffing?
    - [x] Not required
  - Does `run_sql` auto manages the definitions of metadata on renaming?
    - [x] Not required
  - Does `export_metadata`/`replace_metadata` supports the new metadata added?
    - [x] Yes

#### GraphQL
- [x] No new GraphQL schema is generated

#### Breaking changes

- [x] No Breaking changes

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/1593
GitOrigin-RevId: f0582d0be3ed9fadf89e0c4aaf96344d18331dc4
2021-09-29 16:21:05 +00:00
Solomon Bothwell
4e05bdcaec Feature/request transform string interpolation
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2443
Co-authored-by: Tirumarai Selvan <8663570+tirumaraiselvan@users.noreply.github.com>
GitOrigin-RevId: d7d68984d0ae1403bb414572e9704c01ed27deab
2021-09-29 08:14:29 +00:00
Solomon Bothwell
a7cc5df95d Fixes update_action transform bug and updates Kriti pin
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2399
GitOrigin-RevId: 009ee6ec2a3834951e464c232eb517d636ab940a
2021-09-28 01:38:24 +00:00
pranshi06
d916326f4f Change kriti-lang repo protocol from ssh to https
https://github.com/hasura/graphql-engine-mono/pull/2370

GitOrigin-RevId: 0ede9f35f70aaf682bce0499b56be9c49a619ce3
2021-09-16 20:17:03 +00:00
Solomon Bothwell
af5ff07614 Request Transformations
https://github.com/hasura/graphql-engine-mono/pull/1984

Co-authored-by: jkachmar <8461423+jkachmar@users.noreply.github.com>
GitOrigin-RevId: 1767d6bdde48c156fe171b5a9b7e44d7f2eb4869
2021-09-16 11:03:57 +00:00
Brandon Simmons
14d59f5b21 server: use 'text' fork without implicit fusion rules
https://github.com/hasura/graphql-engine-mono/pull/2265

GitOrigin-RevId: 77107555f05cc53323b1aba1149ccb997ca443b4
2021-09-08 04:13:36 +00:00
Robert
3789405e37 multitenant: Improve error messages for schema update
- update pg-client-hs version to provide detailed listen errors
- rework multitenant schema update logging for clarity

https://github.com/hasura/graphql-engine-mono/pull/2185

GitOrigin-RevId: 43569e22df54841cf7637d37744f61f233767762
2021-08-24 15:09:56 +00:00
awjchen
046da3caca Combine oss and pro server configuration
https://github.com/hasura/graphql-engine-mono/pull/1983

GitOrigin-RevId: 91069bd5d1f9c5a166eae2317cf4435220b472b0
2021-08-11 04:19:27 +00:00