Commit Graph
71 Commits
Author SHA1 Message Date
Sulka HaroandGitHub 914ba78f36 Security improvement batch (#6622)
* Adds a new method for the server to push notifies to the client, which require administration privileges from the user. If there are messages in queue but user is not privileged, she is notified of pending messages

* Fix unit tests

* Increase timeouts on tests

* Add translations

* * Aggregate admin messages
* Send admin message on auth fail
* Sending messages over bus
* XSS filtering of objects sent over the REST API

* Warn users if their instance is world readable

* Fix adminnotifies init()

* Fix couple issues from Codacy
2021-01-07 22:46:55 +02:00
Sulka Haro 54008a7122 Remove excess logging 2020-09-22 11:14:13 +03:00
Sulka Haro f878ce115b Add support for CGM data and device statuses. Refactor dataloader to use the new model and reduce queries back down 2020-09-20 18:36:19 +03:00
Sulka Haro 0c7e9bf456 * Require created_at for Treatments on insert
* Refactoring the cache: moved to another file and support flushing from bus events
2020-09-19 18:17:20 +03:00
Sulka HaroandGitHub 801900597a Optimize Nightscout database usage (#5947)
* On periodic polls, only load delta for CGM data, treatments and device statuses
* Serve basic CGM data API queries from in-memory cache. Increases the Nightscout memory footprint but should significantly reduce the Mongo load
* Serve device status, CGM and treatment records from memory cache
* Support count parameter in /profile
2020-09-09 20:11:57 +03:00
JakobandSulka Haro 04edbec7d7 Remove redundant checks on entry ID (#5440) 2020-01-14 15:53:13 +00:00
JakobandSulka Haro 7dc292e056 Resolve unnecessary uses of eslint-ignore (#5436)
* Resolve unnecessary disabling of no-undef eslint rule

* Resolve unnecessary disabling of no-prototype-builtins eslint rule

* Resolve unnecessary disabling of no-unused-vars eslint rule

* Resolve unnecessary disabling of no-empty eslint rule
2020-01-12 20:13:29 +00:00
Jakob Sandberg c4f5ffaf8c Use default entries count instead of distributed number literals 2019-12-05 14:58:58 -08:00
Sulka HaroandGitHub 35c7dc42ce * Allow users to set DE_NORMALIZE_DATES=false to have the REST API denormalize UTC dates to zoned ISO dates in the API (#4826) 2019-07-29 17:21:05 +03:00
Sulka HaroandGitHub e1f0ac59da Small fix for if-modified-since header parsing (#4827) 2019-07-29 17:19:53 +03:00
Sulka Haro bbcd3c55a8 Moved to braces module, which is maintained and doesn't have vulnerable dependencies. Added a mention of EU minimed servers to README. 2019-04-23 16:09:05 +03:00
Jeremy Cunningham 50952dea5c Add entries support for delete query 2018-12-07 17:40:04 -06:00
Sulka HaroandGitHub 6a0e5d91d3 Adds back the support for loading Entries with CSV and TEXT formats (#4114)
* Adds back the support for loading Entries with CSV and TEXT formats

* Add default JSON processing MIME type to request formatting

* Cleanly return a blank string if no entries are found

* Restore TSV output extension, better logging
2018-12-03 23:30:33 +02:00
PieterGit 70aa225616 remove sgvdata 2018-11-20 01:44:52 +01:00
PieterGitandSulka Haro 71103bb4b7 resolve npm audit security fixes (#3721)
* upgrade mocha from 3.5.3 to 5.0.5

This resolves these security issues

  Low             Regular Expression Denial of Service
  Package         debug
  Dependency of   mocha [dev]
  Path            mocha > debug
  More info       https://nodesecurity.io/advisories/534

  Critical        Command Injection
  Package         growl
  Dependency of   mocha [dev]
  Path            mocha > growl
  More info       https://nodesecurity.io/advisories/146

* upgrade mocha and start modularizing lodash to make sure tests pass

* more lodash modularization

* upgrade mqtt to 2.18.3

* allow npm 6.2

* upgrade share2nightscout-bridge

* incorporate express-extension-to-accept into Nightscout

the packages seems not maintained (github page is 404) and has a security issue with mime package.  so upgraded and included into Nightscout code.

if somebody knows a more efficient way of programming this with express4 please PR

* update jsdom for security fixes

* prevent wrapping of hour labels by removing the space

* Revert "update jsdom for security fixes"

This reverts commit 04f1f39d636d8d79c6b01b5f298f9a6cea3dc645.

* Revert "more lodash modularization"

This reverts commit c4fa5304db9f16b94f15c2b44793a5a11d595885.

* remove forever dependency

* Revert "Revert "more lodash modularization""

This reverts commit b13c274ebff0b5c3a48ffc0e610ca85a9f8d25bc.

* fix report.test.js with newer packages

sometimes a fix is very easy. This is to prevent:

```
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: true, _useUTC: true, _l: undefined, _i: T00:00:00, _f: undefined, _strict: undefined, _locale: [object Object]
Error
    at Function.createFromInputFallback (XXX\cgm-remote-monitor\tmp\js\bundle.js:117408:98)
    at configFromString (XXX\cgm-remote-monitor\tmp\js\bundle.js:119456:15)
```

We must use ISO8601 formatted strings and not use slashes in dates, see https://github.com/moment/moment/issues/1407#issuecomment-155630060

* upgrade webpack to 4.16.2

* Update package.json
2018-07-24 20:25:44 +03:00
Sulka HaroandGitHub b579a58333 Add mmol support to OpenAPS temp targets (#3670)
* Fixes issue https://github.com/nightscout/cgm-remote-monitor/issues/3660

* Fix OpenAPS temporary targets using mg/dl on mmol users

* Fixes a bug with saving

* Fix changed entry data order in API

* Clean formatting

* Fix mmol conversion on treatment save
2018-07-08 12:30:59 +03:00
Sulka HaroandGitHub a354405f81 Adds the If-Modified-Since header parsing to api/v1/enties/:spec: calls (#3571) 2018-05-18 09:01:44 +03:00
Sulka Haro 051576056a Moved server-specific sources to their own folder. Removed some unused code as per Codacy reports 2017-12-28 19:15:52 +02:00
Sulka Haro f6f55496d3 Fix a bug with time comparison on if-modified-since support for treatments 2017-10-25 23:16:49 +03:00
Sulka Haro 56a9695744 Remove if-modified-since check for some API calls 2017-01-23 23:24:19 +02:00
Sulka Haro 6018df9c26 Fixing tests 2017-01-02 00:12:28 +02:00
Sulka Haro 437965d67b Now comparing to in-memory data 2017-01-01 23:46:39 +02:00
Sulka Haro 012ba198d1 If-Modified-Since header support for the /entries and /treatments API 2017-01-01 16:34:58 +02:00
Jason Calabrese a8db824977 also support importing extended settings; add IMPORT_CONFIG to readme; clean up 2016-11-05 13:00:08 -07:00
Jason Calabrese a7f734aa84 resolve conflicts and cleanup after merging wip/ddata-endpoints 2016-11-04 00:50:19 -07:00
Ben West de0ff7f1eb Allow aggregating/counting via REST api 2016-08-11 13:36:52 -07:00
Ben West e39ab7ad17 isolate effects of middleware from other routers
Using all(...) in this manner allows middleware from router A to
not affect router B.

As a result, sendJSONStatus and ability to optionally end in
.json disappeared, which this patch also restores.

CC: @jasoncalabrese
With this change, I can successfully restrict reads to entries
vs status vs other things without the middleware leakage we
observed earlier.
2016-08-08 13:45:31 -07:00
Ben West 0f735d0af5 implement read-access against token, mod default
Could see an endpoint changing the global server variable, `defaultRoles` as well.
Seems to work well to disable/enable access really quickly.
2016-08-04 15:40:02 -07:00
Jason Calabrese 3d88bd33a6 replace old wares.verifyAuthorization with ctx.authorization.isPermitted; some refactoring 2016-07-31 20:10:10 -07:00
ericmarkmartin e6328c9190 Changed double to single quotes in lib/api/entries/index.js 2016-04-04 18:06:33 -04:00
ericmarkmartin 406f72edc6 Fixed pr issues from codacy 2016-04-03 01:09:12 -04:00
Ben West 3f0b6be53a fix text endpoints of API
This allows fetching 10k+ records as text.
2016-03-03 13:41:15 -08:00
Milos Kozak 6461bf2a80 codacy on lib/api/entries/index.js 2015-09-24 21:32:49 +02:00
Jason Calabrese 9411a6321f === vs == 2015-09-17 22:25:08 -07:00
Ben West 967c5c7b3c Make DELETE API more usable
Thanks to @MilosKozak for these suggestions.

* Don't crash if lookup by id does not yield any results
* Report errors, if any
* Allow DELETE by ID
* Allow DELETE by wildcard, `*`, to delete all types.
2015-09-17 09:48:14 -07:00
Jason Calabrese f17d7cff22 more codacy issues 2015-09-02 00:09:43 -07:00
Jason Calabrese 4cc825f51f fix some codacy issues 2015-09-01 23:35:25 -07:00
Ben West dc392f1aee tweak docs 2015-09-01 14:31:05 -07:00
Ben West fa11bc09d8 protect delete behind auth 2015-09-01 14:23:32 -07:00
Ben West a927c3502b move delete to be protected by auth 2015-09-01 14:22:51 -07:00
Ben West ba69eb6476 add some docs/comments 2015-09-01 14:21:06 -07:00
Ben West cb6eae3366 more efficient use of regex
If there's only one prefix, use it to help constrain search against index.
2015-09-01 12:40:40 -07:00
Ben West 05eff3f604 add more ways to slice time, update swagger to match 2015-08-30 19:34:51 -07:00
Ben West e143acddbf teach API to slice modal times of days
Expand glob patterns to regexps, optimally, the fast prefix kind.
For @jasoncalabrese, @stavior, @kenstack and friends. :-)
2015-08-30 18:35:55 -07:00
Ben West 92f067bb2f few tweaks for codacy 2015-08-30 15:56:15 -07:00
Ben West fc93b7362d improve echo api 2015-08-30 13:10:29 -07:00
Ben West aca4c6ea74 re-use even more code 2015-08-30 12:52:38 -07:00
Ben West 1c59b33606 add endpoint to explain how queries work
Echo endpoint to debug queries.
2015-08-30 12:06:24 -07:00
Jason Calabrese d224560e4f stop using /entries for treatments and devicestatus; return all type when there isn't a type/id spec in path 2015-08-27 23:08:39 -07:00
Jason Calabrese 269ba27732 clean up prepReqModel and add delete test 2015-08-24 23:23:02 -07:00