Commit Graph

105 Commits

Author SHA1 Message Date
Cody Cutrer fefe3b289f rubocop: Style/RescueModifier helpers, middleware
Change-Id: I6ecafd69e7b338e1b654a7a3cac650da5f606ad8
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/358354
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2024-09-25 17:08:07 +00:00
Cody Cutrer c50cab6c98 drop Rails 7.0 support
closes AE-882

Change-Id: I6d1205e826f3bf83528c957592fbf677a03ab508
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/350884
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
Build-Review: Jacob Burroughs <jburroughs@instructure.com>
Migration-Review: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2024-07-05 15:30:54 +00:00
Cody Cutrer 69e5ebc777 bundle update rubocop
and apply new cop 99% Style/SuperArguments

and a couple Layout/EmptyComment and Style/ArgumentsForwarding that
are found by fixes in those cops

Change-Id: Icc0af9c8065f035bca43868b564f73e8776052f2
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/348626
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jake Oeding <jake.oeding@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Build-Review: Cody Cutrer <cody@instructure.com>
2024-05-30 16:20:52 +00:00
Cody Cutrer a6caa96aa6 rails 7.1: fix schema caching
Change-Id: I8d152eb347cb768d63a31ee250513c7f90e3e3cf
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/339572
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2024-02-05 16:14:47 +00:00
Jacob Burroughs 3b7130c161 Remove a lot of settings
[ignore-stage-results=Flakey Spec Catcher]

refs AE-551

Change-Id: If7b5191c20cfadc438cdc2bc8b489eb2806582fe
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/334831
Reviewed-by: Isaac Moore <isaac.moore@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Jacob Burroughs <jburroughs@instructure.com>
Product-Review: Jacob Burroughs <jburroughs@instructure.com>
2024-01-09 21:32:17 +00:00
Cody Cutrer c32d30f662 bundle update rubocop
[skip-stages=Flakey]
[skip-crystalball]

and apply corrections from new/updated cops:

 * Layout
 * Lint/AmbiguousRange
 * Lint/RedundantSafeNavigation
 * Style/HashEachMethods
 * Style/HashSyntax
 * Style/InverseMethods
 * Style/RedundantLineContinuation
 * Style/RedundantParentheses
 * Style/RedundantReturn
 * Style/SuperWithArgsParentheses
 * Style/SymbolProc

Change-Id: I787e46f5b1c89e0fedebd5452ba74567d66954c1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/334291
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Aaron Ogata <aogata@instructure.com>
Build-Review: Aaron Ogata <aogata@instructure.com>
Migration-Review: Aaron Ogata <aogata@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2023-12-06 14:25:02 +00:00
Cody Cutrer 88a5803982 bundle update redis
closes AE-494

[skip-stages=Flakey]
[skip-crystalball]

several things going on here. in general, many of our monkeypatches
have been implemented in upstream, but in a vastly different way, so
we need to enable/configure those things

 * `servers` is no longer accepted as a backwards compatible
   configuration option; use `url`
 * `database` is no longer accepted as a backwards compatible
   configuration option; you _can_ use `db`, but preferable to
   just use `url`
 * no longer merge together redis.yml and cache_store.yml; if one
   references the other, simply use the config from the other
 * `nil_store` is no longer accepted as a backwards compatible
   configuration option; use `null_store` (almost no one should
   be explicitly using this anyway, so nbd)
 * automatically not-even-trying when redis has previously failed
   is now handled by redis-client's circuit breaker. be sure to
   configure it in redis.yml/cache_store.yml/dynamic settings
 * ignoring redis failures completely is already done by
   RedisCacheStore; just rely on that, except for the few cases
   where we use redis directly. some of these now take advantage
   of a new `failsafe` kwarg (and often in combination with
   pipelining), and some just handle it directly
 * move logging to a RedisClient middleware
 * move Twemproxy disallowed commands to a RedisClient middleware
 * simplify Canvas.lookup_cache_store to have far less special casing
   (in particular, patching is done automatically now)
 * add ability to use Redis::Cluster (configure with `nodes` instead
   of `url`)
 * still override Redis::Distributed's HashRing, so that we don't
   change our ring layout with the new MD5 hashing for servers. but
   we got to vastly simplify the new class, due to upstream
   refactorings allowing us to simply override a single method rather
   than having to re-implement the entire class
 * statsd reporting of redis errors is now simply passed as a callback
   to RedisCacheStore, breaking CanvasCache's dependency on InstStatsd

Change-Id: I787672677a21994d40ae304dbac0fbf3a960a779
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/325641
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Build-Review: Cody Cutrer <cody@instructure.com>
2023-09-28 15:49:47 +00:00
Weston Dransfield b6d24d5006 Consider client_id as identifier for service JWTs
This commit squashes two previously seperate commits.

The individual test plans for each commit have been left intact.

Closes CNVS-59219,CNVS-59187
flag=site_admin_service_auth

Test Plan:
- Restart Canvas after pulling change
- Enable the flag
- Make valid requset to the token endponit using a
  client_credentials grant. To be valid, the following
  must be true:
  - The client_id is a usable developer key global ID
  - The client_secret is the api_key of the dev key
  - The developer key has `internal_service: true`
  - The developer key has an associated `service_user`
- Validate an acess token is returned
- Make an API request using the access token. Note
  that you will need to set the User-Agent header to
  something matching the Instructure service user
  agent regexp. For example:
  ```
  inst-service-ninety-nine/1234567890ABCDEF
  ```
- Tail web logs and validate the client identifier
  use by request throttling middleware is:
  ```
  service_user_key:<global developer key ID>"
  ```

Change-Id: I214823b708fedb3e811f123cb986a955f37b95c0

Allow blocking inst_access tokens by jti claims

Test Plan:
- Restart Canvas after pulling change
- Enable the flag
- Make valid requset to the token endponit using a
  client_credentials grant. To be valid, the following
  must be true:
  - The client_id is a usable developer key global ID
  - The client_secret is the api_key of the dev key
  - The developer key has `internal_service: true`
  - The developer key has an associated `service_user`
- Make an API request using the access token. Note
  that you will need to set the User-Agent header to
  something matching the Instructure service user
  agent regexp. For example:
  ```
  inst-service-ninety-nine/1234567890ABCDEF
  ```
- Tail web logs and validate the client identifier
  use by request throttling middleware is:
  ```
  service_user_key:<global developer key ID>"
  ```
- Decode the access token and note the `jti` claim value
- In a Canvas Rails console, add that jti value to
  the request throttling blocklist:
  ```
  Setting.set("request_throttle.blocklist", <jti value>)
  ```
- Attempt to use the token again and validate the http
  response code is 403
- Attempt to make an API request with a standard access
  token and validate throttling middlware does not raise
  an error
- Attempt ot make a request with an active session and validate
  throttling middleware does not raise an error

Change-Id: Ia8448094b7bf0281268bc3dd2d027bb934aa595c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/323766
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Daniel Matyas Vincze <daniel.vincze@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2023-09-26 22:01:14 +00:00
Cody Cutrer 09a6b94036 add reasonable failsafes for several usages of Consul
refs AE-380

a lot of these are APM style settings that would be okay to just turn
off while Consul is down. others are things that should just silently
not have any data, instead of failing the request

Change-Id: I34c553b089197f85b2d46029e5079851227090b6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/322239
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Isaac Moore <isaac.moore@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2023-07-12 14:51:15 +00:00
Jacob Burroughs 7dcc507d0a Rubocop for ruby 3.1
[skip-stages=Flakey]

Change-Id: I6abefdfa9fed6dd4525c8786e93efa548b3710f2
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/319603
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Isaac Moore <isaac.moore@instructure.com>
QA-Review: Jacob Burroughs <jburroughs@instructure.com>
Product-Review: Jacob Burroughs <jburroughs@instructure.com>
Build-Review: Jacob Burroughs <jburroughs@instructure.com>
Migration-Review: Jacob Burroughs <jburroughs@instructure.com>
2023-06-06 16:44:26 +00:00
Cody Cutrer 502aa068da rubocop: Layout/Multiline*LineBreaks
[skip-stages=Flakey]

Change-Id: I24912809267088bc19a4082c49bc5f78ca7b76bb
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/317302
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
Build-Review: Jacob Burroughs <jburroughs@instructure.com>
Migration-Review: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2023-05-01 19:31:42 +00:00
Cody Cutrer 7c37aa5f64 rubocop: prep for updating rubocop-rails
auto-correctable cops applied

[skip-stages=Flakey]

Change-Id: Ie80bdfd170d9233d4a750edce6be467c93f3493f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/315835
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2023-04-14 14:07:22 +00:00
Dustin Cowles 47ba763c40 make sasu user-agent additional fields optional
closes QUIZ-10980
flag=none

Test plan:
- Specs Pass

Change-Id: Ibcf14a5356f9c20ece0cbcd6dc76c27faf22f483
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/315158
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: James Logan <james.logan@instructure.com>
Reviewed-by: Stephen Kacsmark <skacsmark@instructure.com>
QA-Review: James Logan <james.logan@instructure.com>
Product-Review: Stephen Kacsmark <skacsmark@instructure.com>
2023-04-12 14:50:53 +00:00
Dustin Cowles f921fffb9a allow throttling by site admin service user key
refs QUIZ-10507
flag=none

Test plan:
- PreReqs
 - Canvas with two shards
 - An account with user on each shard
- Create an AccessToken for each user
 - at1=AccessToken.create!(developer_key: DeveloperKey.create!(account:
   account1)
 - at2=AccessToken.create!(developer_key: DeveloperKey.create!(account:
   account2))
- Run AccessToken.site_admin?(at1.full_token)
 - Observe response is `true`
- Run AccessToken.site_admin?(at2.full_token)
 - Observe response is `false`
- Configure an HTTP client with a key on site admin
- Add the key to the approvelist:
 - Setting.set("request_throttle.approvelist", "service_user_key:<id>")
- Restart web container and connect to console and run commands:
 - `GuardRail.activate!(:deploy)`
 - `Rails.cache.redis.keys`
 - Confirm no `request_throttling:` keys exist
- Send a Canvas API request from HTTP client
- run `Rails.cache.redis.keys` again
- Observe `request_throttling:service_user_key:<id>` key exists
- Configure HTTP client to use the non-site-admin key (at2)
- Send a Canvas API request from HTTP client
- run `Rails.cache.redis.keys` again
- Observe NO `request_throttling:service_user_key:<id>` key exists

Change-Id: I16e591a9062701849d792fe0293580999ae8a613
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/309604
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: Mark McDermott <mmcdermott@instructure.com>
Product-Review: Stephen Kacsmark <skacsmark@instructure.com>
2023-03-29 17:51:09 +00:00
Isaac Moore d6584b490a Remove unnecessary require statements
closes AE-30

flag=none

test plan:
- verify Canvas boots in CD
- verify no influx of new errors in CD

[fsc-timeout=30]

Change-Id: Ifa04bebe1b09f01c6d3b8b2d8f3bb424759730f5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/308067
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Isaac Moore <isaac.moore@instructure.com>
Product-Review: Isaac Moore <isaac.moore@instructure.com>
Build-Review: James Butters <jbutters@instructure.com>
2023-01-04 21:38:21 +00:00
Evan Battaglia 1bebaaaece Throttle LTI Advantage endpoints by client_id
closes INTEROP-7669
flag=none

Test plan:
- Open a rails console and run
    GuardRail.activate!(:deploy)
    Rails.cache.redis.keys
  To see the list of redis keys.
- Hit an AGS or NRPS endpoint. Look at the list of keys and check that
  there is now a key we use throttling redis keys based on the client ID
  "request_throttling:lti_advantage:123-" where 123 is the developer key
  ID.
- If you test on an MRA install where "shard.database_server_id" is not
  empty, you will see that that key actually includes the
  database_server_id.

Change-Id: Ied277f948df4885c345c3a2ee9dbfc505feec405
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/307178
Reviewed-by: Xander Moffatt <xmoffatt@instructure.com>
QA-Review: Xander Moffatt <xmoffatt@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Product-Review: Evan Battaglia <ebattaglia@instructure.com>
2022-12-22 14:21:13 +00:00
Isaac Moore dba611db24 Improve Sentry APM sampling decisions
Some clients calling Canvas are including their own sentry-trace header,
which is a header designed to associate traces from multiple services
together; if that header is present, Sentry decides that the transaction
should be sampled to maintain the association.

This change discards the `sentry-trace` header unless there is also a
`Referrer` header which contains the same host the request is for.

This change also switches to using a proc to define the APM sample rate,
which will allow the sample rate to be updated without restarting app
servers.

flag=none
closes DE-1029, DE-1028

test plan:
- verify that tracing can still be enabled/disabled by modifying the
  sampling rate
- verify that calling Canvas with a `sentry-trace` header does not
  override the sampling rate, unless a same-origin `Referrer` header is
  also present

Change-Id: Iddc80c3234975db0e45fa8defcba8eda1f4e0d24
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/284485
Reviewed-by: Ryan Norton <rnorton@instructure.com>
Product-Review: Ryan Norton <rnorton@instructure.com>
QA-Review: Isaac Moore <isaac.moore@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2022-02-05 00:17:52 +00:00
Aaron Ogata 2f386d104a rename Canvas::DynamicSettings => DynamicSettings
Change-Id: Ia2c1754ce729d95bcbf194f6b31a5a2b36d42bbb
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/282694
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Charley Kline <ckline@instructure.com>
QA-Review: Charley Kline <ckline@instructure.com>
Product-Review: Charley Kline <ckline@instructure.com>
2022-01-12 21:54:51 +00:00
Cody Cutrer c2cba46851 RuboCop: Style/StringLiterals, Style/StringLiteralsInInterpolation
[skip-stages=Flakey]

auto-corrected

Change-Id: I4a0145abfd50f126669b20f3deaeae8377bac24d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279535
Tested-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
2021-11-25 14:03:06 +00:00
Cody Cutrer 04e28fd25c RuboCop: Style/Next
[skip-stages=Flakey]

auto-corrected

Change-Id: Ia842e948dc2f6f0eb2d39a66e1c56cc4fe90bd5c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279168
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-23 14:29:04 +00:00
Cody Cutrer eecafdca0b RuboCop: Style/NegatedIfElseCondition
[skip-stages=Flakey]

auto-corrected

Change-Id: I973e75a76d2103c802fab2c52676baf080bd516d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279080
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-20 21:09:31 +00:00
Cody Cutrer ff99d18138 RuboCop: Style/RedundantSelf
[skip-stages=Flakey]

auto-corrected

Change-Id: I5f26ad1f8210a74c2198b514235d5134dcd0dae1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279070
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2021-11-20 16:41:21 +00:00
Cody Cutrer c4bc112611 RuboCop: Style/MethodCallWithoutArgsParentheses
[skip-stages=Flakey]

auto-corrected

Change-Id: Idcbd419ab2196101398715e6b8cdd8d70ae5c587
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278698
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
2021-11-18 23:07:30 +00:00
Cody Cutrer fe75025e1d RuboCop: Style/RegexpLiteral
[skip-stages=Flakey]

auto-corrected

Change-Id: I98a7afefcbb3631ee046e45fcfc9f955ca7ddca8
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278636
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-18 02:08:34 +00:00
Cody Cutrer b70d3ab89d RuboCop: Style/SingleLineMethods, Style/Semicolon
[skip-stages=Flakey]

auto-corrected

Change-Id: Ib94ed586a0d5bf4985a5367144d398eeee706303
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278138
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-12 18:39:32 +00:00
Cody Cutrer a690e90aa8 RuboCop: Style/RedundantReturn
[skip-stages=Flakey]

auto-corrected

Change-Id: Ic472ca1cc04423fc966cd4a1ead467604d2904fc
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278130
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-12 16:33:45 +00:00
Cody Cutrer 1832881748 RuboCop: Performance/RegexpMatch
[skip-stages=Flakey]

auto-corrected

Change-Id: Icf79dc86947cde22d0853b3db8afa3db853e7b8a
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278013
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-11 22:02:06 +00:00
Cody Cutrer 7fdf9d7588 RuboCop: Lint
[skip-stages=Flakey]

the balance. mostly. Lint/UriEscapeUnescape is put in the pending
block because it's so touchy, and I didn't want to deal with it
right now

all manual

Change-Id: Ibeb81e013f56f160d51f7d237a9bcfe98daa1e53
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277569
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-09 21:42:31 +00:00
Cody Cutrer 0321c40e94 RuboCop: Lint/ConstantDefinitionInBlock app, config, gems, lib
all except for spec

all manual

Change-Id: I8d4f118598ad7521b705a52d1133097b17f94393
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277228
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-02 01:34:48 +00:00
Cody Cutrer d4d27313fb RuboCop: Lint/UnusedMethodArgument partial
app except for app/models, config

all manual. many cases I removed the unused argument entirely, and
updated callers to not send it

there were also a few "override this method and raise an exception so
you don't use it cause rails is changed" methods that were for old
rails versions that I just removed completely

Change-Id: I071a5a8266801427c5c7a157fefe14850495e620
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/276446
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-10-21 13:39:12 +00:00
Cody Cutrer b973c7ca27 RuboCop: Style/ParenthesesAroundCondition
[skip-stages=Flakey]

(auto-corrected)

this complements Lint/AssignmentInCondition

Change-Id: I8e621631cb8565cc6062398cfab714f61b485cad
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274747
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-30 12:59:18 +00:00
Cody Cutrer 5e3e922307 RuboCop: Layout app
Change-Id: I4cf9600c9636a66509f1ab183b936381ea0aefb4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274156
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-22 19:35:01 +00:00
Cody Cutrer c6054e8308 add consul failsafes to several request-critical paths
Change-Id: I8d81da166a2d7fb79da1e722135d59b18b6e7825
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/270783
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-08-06 21:32:02 +00:00
Cody Cutrer 4819bc6df1 fix class method call
Change-Id: I0058ed6058261aacfddd501bb6c461f4182184f0
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/263959
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jeffrey Johnson <jeffrey.johnson@instructure.com>
QA-Review: Jeffrey Johnson <jeffrey.johnson@instructure.com>
Product-Review: Jeffrey Johnson <jeffrey.johnson@instructure.com>
2021-04-29 23:33:06 +00:00
Cody Cutrer 883ef02950 use SchemaCache for schema caching
instead of lower level on the adapter itself, because it causes surprises
when normally uncached methods are suddenly cached

also extend schema caching to jobs nodes

note that we can directly cache SchemaCache objects because it explicitly
implements marshal_dump, which is how Rails intends it to be used (just
with a file, instead of a cache store).

Change-Id: Id61d14ccc1fa9b44435c25f68063bbc5b6ddbaed
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/263004
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-04-29 20:31:01 +00:00
Kyle Rosenbaum 71a07b011b Revert "detect client's disconnecting during requests"
This reverts commit 0d2156f6ff.

Reason for revert: Investigating Build Timeout Issues

Change-Id: I88317817bd2f74a9b96c1bc5da5d8d943e971bba
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/261956
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-04-15 20:44:09 +00:00
Cody Cutrer 0d2156f6ff detect client's disconnecting during requests
and abort the request

test plan:
 * add something  like `User.connection.execute("SELECT pg_sleep(30)")` to a
   controller action like Login::CanvasController#new
 * use curl to call it (`curl http://localhost:3000/login/canvas`)
 * ctrl-c the curl request
 * notice the server immediately "responds" with a 408, and check that
   the query is no longer active in the db (with
   `SELECT * FROM pg_stat_activity` and checking the `state` column;
   the last query will still be `SELECT pg_sleep(30)`)

Change-Id: Iabd3268ef70e4f036ea1c0fc60865697b123a09a
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/261781
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2021-04-15 18:34:10 +00:00
Cody Cutrer ab1c82dd21 ensure LoadAccount clears things after each request
not before, since specs might run stuff afterwards

Change-Id: I769794844c0d411255561cd83a74de3b4eeb0c4d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/262838
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Reviewed-by: Wagner Goncalves <wagner.goncalves@instructure.com>
2021-04-13 21:34:01 +00:00
Cody Cutrer 0c0e8fac31 add frozen_string_literal_comment to remaining app files
Change-Id: Ib9a170d264ca3ac5acee5147baae9385c9a693f9
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/261811
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2021-03-30 17:51:08 +00:00
Ethan Vizitei c5988b8cc5 Initial work on getting zeitwerk loader running
refs FOO-1712
flag=none

 - drop bad directories from autoloading (jsx)
 - re-inflect some things that zeitwerk doesn't
   know by default (InstFS, etc)
 - add environment variable trigger for enabling
   zeitwerk loading
 - move samesite transition cookie to app middleware
   so we don't try to reload middleware
 - use zeitwerk.rb shim to pre-load things
   that are not correctly loaded by their own
   gems

TEST PLAN:
  1) everything continues to work fine
  2) for local development, if you use the
     CANVAS_ZEITWERK env var, you get zeitwerk
     autoloading (which is probably still broken)

Change-Id: I55a0db84034133240698bf4ff0cc8d225ec181a6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/260674
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-03-16 19:55:12 +00:00
Ethan Vizitei dd58f89f2c request_context as a gem
refs FOO-1649

Pull out middleware for request
context to a gem so that other
engines in canvas can use the
generator to look at the current
request for standard attributes
in the same way.

TEST PLAN:
  1) requests should keep on getting context ids
  2) sessions should keep getting added to the cookie jar

Change-Id: I9245491f722ac29c9544623ee14e0771ae248cd4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/259609
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Ethan Vizitei <evizitei@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2021-03-02 23:02:40 +00:00
Ethan Vizitei 676ab0a310 extract PageViewJwt from PageView
refs FOO-1648
flag=none
[fsc-propagate=false]

RequestContextGenerator depends on
the PageView model so that it can
extract these attributes.  Pull
that responsibility out into canvas_security
to de-circularize that dependency chain.

TEST PLAN:
  1) RequestContext page view token decoding
     does exactly what it does right now
  2) specs continue to pass

Change-Id: If9dfa923338f2b67490593771d58e9610f514923
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/259613
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2021-03-02 22:01:22 +00:00
Cody Cutrer 334cfe734c moar frozen string literal fixes
Change-Id: Ibb415c8b346983eb551668b0422a04d60d6e2857
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/253020
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-11-17 22:06:13 +00:00
Simon Williams 132295ad26 Revert "add debugging around potential request throttle config issue"
This reverts commit 89a9f28033.

refs FOO-949

Change-Id: Icca2563c670de8c7a0513d709aeb2c2541e37d3e
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/248195
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
2020-10-07 01:05:12 +00:00
Cody Cutrer 3d1ca55209 rename request throttle to approvelist and blocklist
(allowed? is already used)

closes FOO-991

test plan:
 * sanity check of request throttling

Change-Id: I366cb237a5b7edb52808f3b53098a959ad9c8056
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/249250
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-10-06 22:06:52 +00:00
Cody Cutrer 66a8d4d4ef allow comments in blocklist entries
so we know where they came from

Change-Id: I41d58d73c99d1187064f7d83821f361d3d73791f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/249256
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-10-06 20:10:19 +00:00
Jacob Burroughs 567915c07e Move all reload hooks into on_reload blocks
Change-Id: Ia1901b9ec0dd621234dd2cab88ad03b51fe1be16
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/248633
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Jacob Burroughs <jburroughs@instructure.com>
Product-Review: Jacob Burroughs <jburroughs@instructure.com>
Reviewed-by: Michael Ziwisky <mziwisky@instructure.com>
2020-10-06 14:16:04 +00:00
Simon Williams 89a9f28033 add debugging around potential request throttle config issue
refs FOO-949

test plan: requests succeed with request_throttle config in place

Change-Id: If882cc683fbfcb6b2be9c87827934506203df55d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/247320
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-09-10 17:55:49 +00:00
Ethan Vizitei c79f946e83 don't reserve capacity for blacklist
Change-Id: I90f224a03228977cd5a3ea1b130536f7fb24ad3d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/246242
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2020-08-27 18:41:45 +00:00
Ethan Vizitei d732b7a180 don't reserve capacity for whitelisted requests
Change-Id: Ic0fabd4f0799afeb3337e439a93c3d31cb0873a4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/245882
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Ethan Vizitei <evizitei@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2020-08-24 19:07:55 +00:00