Git Product home page Git Product logo

argus's People

Contributors

denopink avatar dependabot[bot] avatar j-mai avatar jc000 avatar joe94 avatar kcajmagic avatar kristinapathak avatar maurafortino avatar mkocot avatar mtrinh11 avatar piccione99 avatar renaz6 avatar sachin4403 avatar schmidtw avatar utsavbatra5 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

argus's Issues

argus returns 403 instead of 404 from non-existent endpoint

Submitting a PUT request to non-existent endpoint with the correct auth results in a 403, instead of a 404 as expected.
Example:
curl -X PUT https://$argus_server:443/v10 -H "Authorization:$basicauth" -d '{"identifier" : "safepayload","data": {"year":1967,"words": ["What", "a", "Wonderful", "World"]},"ttl" : 300}' -i
HTTP/1.1 403 Forbidden
X-Midt-Server: argus
X-Midt-Version: 0.3.4
Date: Wed, 05 Aug 2020 22:13:54 GMT
Content-Length: 0
Connection: close

Support a directory of configuration files.

Ideally it would great to be able to have a directory of configuration files that are loaded and used for configuration. In this way, we can more easily separate out the configuration from the secrets.

argus returns 500 error for bad request

Our testing configuration uses dynamodb. I submitted a nested json object (512 deep) to argus. This results in a 500 error as dynamodb supports up to 32 deep nested objects.
The error returned is:
Request Failed: "ValidationException: Nesting Levels have exceeded supported limits: Attributes in the item have nested levels beyond supported limit\n\tstatus code: 400, request id: [redacted]"
dynamodb returns a 400, we should probably return a 400 to the user rather than a 500 as this is an error in the user request.

ttl can go negative

After storing an item the ttl can be negative when retrieved

  1. store an item with a short ttl
    {"identifier":"payload3","data":{"qa3":"qa3"},"ttl":5}

  2. query repeatedly for the item

  3. the item returned can hav a negative ttl
    {"identifier":"payload3","data":{"qa3":"qa3"},"ttl":-3}

Rename master branch to main

Also have to change references to the branch in .travis.yml, README, and CONTRIBUTING. Double check any other markdown files as well - sometimes links have the branch name in them.

Owner shouldn't change after item creation

The authorized() check allows super users to bypass a check if the item owner provided in the request matches the owner stored:

func authorized(adminMode bool, resourceOwner, requestOwner string) bool {

In the set endpoint, we push this item:

err = s.Push(setItemRequest.key, setItemRequest.item)

which is set up in transport:
https://github.com/xmidt-org/argus/blob/main/store/transport.go#L115

For normal users, the owners have to match so it's not an issue. But because super users bypass this check, it allows them to modify the owner field. My suggested fix is to check or overwrite any fields we don't want to change after getting the item already stored.

A few questions:

  • If a super user provides an owner and it doesn't match the item there, do we fix the item they want to store or return a non-200 status?
  • Are there any other fields that shouldn't be modified?

argus returns unfiltered errors from underlying db

Argus directly returns raw errors from the underlying db. Our test configuration uses dynamodb. One testcase submitted a 512 deep nested object which exceeded dynamodb's 32 deep limit. The error header returned was:
X-Xmidt-Error: Request Failed: "ValidationException: Nesting Levels have exceeded supported limits: Attributes in the item have nested levels beyond supported limit\n\tstatus code: 400, request id: [redacted]"
We probably shouldn't return the error messages directly as we could accidentally expose important information from the underlying db (security) or other sensitive information. We would be relying on the underlying db to filter its error messages.

bucket names are not sanitized

argus will accept many different characters as bucket names. For example \ is considered valid.
e.g
curl -H "Authorization:$basicauth" 'https://$argusserver:443/api/v1/store/\' -d '{"identifier" : "payload3","data":{"qa3":"qa3"},"ttl":300}' -i -X PUT
returns:
{"bucket":"\\","id":"tPO9_4P78gMPbmDA6_XxhJRrhIVUguLgK0Mgf0ztHrc"}

Also note that the bucket name returned is \\ instead of \
To retrieve you still need \ as in
curl -X GET -i -H "Authorization:$basicauth" 'https://$argusserver:443/api/v1/store/\'

Reword comments

A couple of things we could change:

  • // Bucket is a collection of items.

    "Bucket is the name of the grouping to which this item belongs" might be better

  • Review comments and ensure they align with the different storage options we offer (inmem, cassandra, dynamo)

identifier is a required field name

argus no longer requires identifier as it should. In previous builds it was required and the documentations states that it should be.

curl -i -H "Authorization: $basicauth" https://[argus-server]:443/api/v1/store/Joel2222 -d '{"data": {"year":1967,"words": ["What", "a", "Wonderful", "World"]},"ttl" : 300}' -X PUT -H "X-Midt-Owner: joel"
HTTP/1.1 200 OK
Content-Type: application/json
X-Midt-Server: argus
X-Midt-Version: 0.3.6
Date: Tue, 06 Oct 2020 23:24:20 GMT
Content-Length: 72
Connection: close
{"bucket":"Joel2222","id":"47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU"}

Deleting resources with an owner

Right now, a delete request without an owner header is able to delete resources that have an owner header. Is that what is wanted? Shouldn't it be that only the owner of the resource is allowed to delete it?

Group scattered configuration components related to authentication

Context

Currently, our services all share very similar config and setup code for authentication. However, the configuration keys are sometimes different and there's not an easy to tell how the keys relate to each other besides the comments we added to the sample yaml files. It also makes it a bit more challenging to have shared setup code that works for all different services.

Since Argus is still at an early stage, this might be a good time to try a new structure at least for all values related to authentication.

Suggested idea

The suggested structure stems from the idea that authentication can be both inbound (authenticating incoming requests) and outbound (obtaining credentials to access external services). For inbound authentication, we've mostly been working with basic and bearer types but there is no limitation in adding new ones. For outbound authentication, although it seems a bit open form, the tool or service we are trying to access often determines which credential needs to be used.

More concretely, take a look at the current and suggested structures:

Current configuration structure

##############################################################################

Suggested structure:

authentication:

Benefits:

  • Our config files will be easier to visually digest and understand the relationship between different config values related to authentication. For example, one no longer needs to rely as much on the comments to understand that capabilityChecks, authHeader and jwtValidator are all part of the same authentication process.
  • For inbound authentication, it might make it easier to write bascule helper methods to create validators that work across different services. It'll remove some duplicated code.

Challenges:

  • The config is less flat than current one.
  • It will be a big change if we wanted to propagate to all existing services. However, we could make it the standard for new services. @kristinaspring mentioned that this is also compatible with some of our newer internal services.

Chrysom readme

Chrysom, the client library, isn't mentioned in the argus readme. It would be nice if it had a readme of its own.

Don't change the identifier in the item saved to the store

Currently, when generating a key for a push request, the identifier that the client provides is overridden by the hashed key in this line:

item.Identifier = transformPushItemID(item.Identifier)

The user provided identifier should be saved as part of the resource. the push request object should probably include a Model.key as part of the struct instead. This way, when the user grabs all the resources or that specific resource, they can see the identifier they provided.

Super user feature refactor (JWTs only)

The super user feature is currently implemented through the X-Midt-Admin-Token header. That is, Argus knows whether a request is allowed to execute an operation based on whether the header value matches a configured secret.

Now, the team proposed to abandon this header approach and instead get the information from the existing authentication token (leveraging the bascule module).

At a high level, we want

  • the ability to encode information in the JWT that indicates a request can run as super user (i.e. not having a capability might mean your request runs in "normal" mode while having a capability means you run as "super user").
  • the ability to pass this information down to the handlers to use.

Using the current basculechecks, an AlwaysTrueCheck could be used along with having the handlers look at the capabilities to find if the request is in user mode or not but I wanted to hear your thoughts @kristinaspring @johnabass about if and how we could extend bascule to accommodate this use case.

argus allows duplicate field names

argus accepts json payloads with non-unique object names:
e.g.
{"identifier" : "minimal0","data": {"mini":"mouse"},"ttl":300,"identifier" : "minimal1","data": {"mini":"mouse"},"ttl":600}

which is stored as (ignore ttl decreasing value):
{"identifier":"minimal1","data":{"mini":"mouse"},"ttl":578}

It replaces the value of the first occurrence with the value of the last occurrence of the name. The json syntax doesn't require unique identifiers. The json lint validator flags this as invalid json.

Unused handler dependency

argus/routes.go

Line 105 in 803454a

Handler store.Handler `name:"setHandler"`

It looks like this was the original handler, but now that the handlers have been split up, we don't use it. We do check if it's nil, but that doesn't seem necessary. Can we remove this field and the nil check?

API change proposal

  1. Change UUID field name to ID: let's do this if we won't be enforcing this field to be an actual UUID.

  2. Drop the Identifier field: unless there's a good reason for Argus to keep it, we should simply drop this and let users have it as part of their data payload.

  3. Drop explicit use of an AdminToken header for super user feature: although the idea of a super user is still desired, the team proposed that information should be conveyed as part of the authentication token through bascule.

  • JWTs: a capability could convey that information.
  • Basic Auth: perhaps a configurable allowList could help.

argus merges the data fields for duplicate names

Currently, Argus accepts json payloads with duplicate object names e.g.
{"identifier" : "minimal0","data": {"minnie":"mouse"},"ttl":300,"identifier" : "minimal1","data": {"mickey":"mouse"},"ttl":600}

This is what's stored:
{"identifier":"minimal1","data":{"mickey":"mouse","minnie":"mouse"},"ttl":572}

Non-unique names appeared to be allowed in json, but this results in inconsistent behavior. The value for identifier & ttl are replaced by the later duplicate, but data field values are merged.

Generic values in Argus

@kristinaspring had the thought here https://github.com/xmidt-org/argus/pull/44/files#r490619697 that we may want to make values such as the header key for the Item Owner (currently X-Midt-Owner).

While it might be okay to leave this as is for simplicity and because Argus is a "Xmidt" product, making Argus less tied to hardcoded values related to XMiDT might make it more open source friendly.

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.