Giter Site home page Giter Site logo

zero2prod's Introduction

My adventures in Luca Palmieri's Zero To Production In Rust.

Make sure you have the following installed:

To start up the PostgreSQL and Redis databases in a detached Docker container:

./scripts/init_db.sh
./scripts/init_redis.sh

Once the databases are running, it's possible to build, run or test in the local environment with cargo build, cargo run or cargo test, respectively.

Once the database is running, it's also possible to statically prepare the binary's SQL queries. This repo already includes the result sqlx-data.json, but if necessary this can be generated using (might need to cargo clean first):

cargo sqlx prepare -- --bin zero2prod

To run in the production environment (the first command just checks if sqlx-data.json is populated correctly):

cargo sqlx prepare --check -- --bin zero2prod
sudo docker build --tag zero2prod --file Dockerfile .
sudo docker run -p 8000:8000 zero2prod

With the app running in either the local or production environment, you can navigate to http://localhost:8000/login, or simulate client requests using commands such as:

curl -v http://127.0.0.1:8000/health_check
curl -vd "name=le%20guin&email=ursula_le_guin%40gmail.com" http://127.0.0.1:8000/subscriptions

To deploy the app on DigitalOcean's servers:

doctl apps create --spec spec.yaml

To speed up the inner development loop, install a fast linker (see "LLVM stuff" above), then

cargo install bunyan
cargo install cargo-watch
cargo watch -x check -x test -x "run | bunyan"

Note: last I checked, there seems to be a problem with the production environment, where the cargo sqlx prepare --check and docker run commands both fail.

zero2prod's People

Watchers

 avatar  avatar  avatar

zero2prod's Issues

RUSTSEC-2020-0048: Use-after-free in BodyStream due to lack of pinning

Use-after-free in BodyStream due to lack of pinning

Details
Package actix-http
Version 3.0.0-beta.1
URL actix/actix-web#1321
Date 2020-01-24
Patched versions >=2.0.0-alpha.1

Affected versions of this crate did not require the buffer wrapped in BodyStream to be pinned,
but treated it as if it had a fixed location in memory. This may result in a use-after-free.

The flaw was corrected by making the trait MessageBody require Unpin
and making poll_next() function accept Pin<&mut Self> instead of &mut self.

See advisory page for additional details.

RUSTSEC-2018-0019: Multiple memory safety issues

Multiple memory safety issues

Details
Package actix-web
Version 4.0.0-beta.1
URL actix/actix-web#289
Date 2018-06-08
Patched versions >=0.7.15

Affected versions contain multiple memory safety issues, such as:

  • Unsoundly coercing immutable references to mutable references
  • Unsoundly extending lifetimes of strings
  • Adding the Send marker trait to objects that cannot be safely sent between threads

This may result in a variety of memory corruption scenarios, most likely use-after-free.

A signficant refactoring effort has been conducted to resolve these issues.

See advisory page for additional details.

[Security] Workflow scheduled-audit.yml is using vulnerable action actions/checkout

The workflow scheduled-audit.yml is referencing action actions/checkout using references v1. However this reference is missing the commit a6747255bd19d7a757dbdda8c654a9f84db19839 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

RUSTSEC-2020-0159: Potential segfault in `localtime_r` invocations

Potential segfault in localtime_r invocations

Details
Package chrono
Version 0.4.19
URL chronotope/chrono#499
Date 2020-11-10

Impact

Unix-like operating systems may segfault due to dereferencing a dangling pointer in specific circumstances. This requires an environment variable to be set in a different thread than the affected functions. This may occur without the user's knowledge, notably in a third-party library.

Workarounds

No workarounds are known.

References

See advisory page for additional details.

RUSTSEC-2020-0049: Use-after-free in Framed due to lack of pinning

Use-after-free in Framed due to lack of pinning

Details
Package actix-codec
Version 0.4.0-beta.1
URL actix/actix-net#91
Date 2020-01-30
Patched versions >=0.3.0-beta.1

Affected versions of this crate did not require the buffer wrapped in Framed to be pinned,
but treated it as if it had a fixed location in memory. This may result in a use-after-free.

The flaw was corrected by making the affected functions accept Pin<&mut Self> instead of &mut self.

See advisory page for additional details.

RUSTSEC-2020-0071: Potential segfault in the time crate

Potential segfault in the time crate

Details
Package time
Version 0.1.44
URL time-rs/time#293
Date 2020-11-18
Patched versions >=0.2.23
Unaffected versions =0.2.0,=0.2.1,=0.2.2,=0.2.3,=0.2.4,=0.2.5,=0.2.6

Impact

Unix-like operating systems may segfault due to dereferencing a dangling pointer in specific circumstances. This requires an environment variable to be set in a different thread than the affected functions. This may occur without the user's knowledge, notably in a third-party library.

The affected functions from time 0.2.7 through 0.2.22 are:

  • time::UtcOffset::local_offset_at
  • time::UtcOffset::try_local_offset_at
  • time::UtcOffset::current_local_offset
  • time::UtcOffset::try_current_local_offset
  • time::OffsetDateTime::now_local
  • time::OffsetDateTime::try_now_local

The affected functions in time 0.1 (all versions) are:

  • at
  • at_utc
  • now

Non-Unix targets (including Windows and wasm) are unaffected.

Patches

Pending a proper fix, the internal method that determines the local offset has been modified to always return None on the affected operating systems. This has the effect of returning an Err on the try_* methods and UTC on the non-try_* methods.

Users and library authors with time in their dependency tree should perform cargo update, which will pull in the updated, unaffected code.

Users of time 0.1 do not have a patch and should upgrade to an unaffected version: time 0.2.23 or greater or the 0.3 series.

Workarounds

No workarounds are known.

References

time-rs/time#293

See advisory page for additional details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.