1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-24 07:42:40 +01:00
phorge-phorge/src/applications/repository
epriestley a0d4b6da4b Support (but do not actually enable) a maximum file size limit for Git repositories
Summary:
Depends on D19816. Ref T13216. See PHI908. See PHI750. In a few cases, users have pushed multi-gigabyte files full of various things that probably shouldn't be version controlled. This tends to create various headaches.

Add support for limiting the maximum size of any object. Specifically, we:

  - list all the objects each commit touches;
  - check their size after the commit applies;
  - if it's over the limit, reject the commit.

This change doesn't actually hook the limit up (the limit is always "0", i.e. unlimited), and doesn't have Mercurial or SVN support. The actual parser bit would probably be better in some other `Query/Parser` class eventually, too. But it at least roughly works.

Test Plan:
Changed the hard-coded limit to other values, tried to push stuff, got sensible results:

```
$ echo pew >> magic_missile.txt && git commit -am pew && git push
[master 98d07af] pew
 1 file changed, 1 insertion(+)
# Push received by "local.phacility.net", forwarding to cluster host.
# Acquiring write lock for repository "spellbook"...
# Acquired write lock immediately.
# Acquiring read lock for repository "spellbook" on device "local.phacility.net"...
# Acquired read lock immediately.
# Device "local.phacility.net" is already a cluster leader and does not need to be synchronized.
# Ready to receive on cluster host "local.phacility.net".
Counting objects: 49, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (48/48), done.
Writing objects: 100% (49/49), 3.44 KiB | 1.72 MiB/s, done.
Total 49 (delta 30), reused 0 (delta 0)
remote: +---------------------------------------------------------------+
remote: |      * * * PUSH REJECTED BY EVIL DRAGON BUREAUCRATS * * *     |
remote: +---------------------------------------------------------------+
remote:              \
remote:               \                    ^    /^
remote:                \                  / \  // \
remote:                 \   |\___/|      /   \//  .\
remote:                  \  /V  V  \__  /    //  | \ \           *----*
remote:                    /     /  \/_/    //   |  \  \          \   |
remote:                    @___@`    \/_   //    |   \   \         \/\ \
remote:                   0/0/|       \/_ //     |    \    \         \  \
remote:               0/0/0/0/|        \///      |     \     \       |  |
remote:            0/0/0/0/0/_|_ /   (  //       |      \     _\     |  /
remote:         0/0/0/0/0/0/`/,_ _ _/  ) ; -.    |    _ _\.-~       /   /
remote:                     ,-}        _      *-.|.-~-.           .~    ~
remote:   *     \__/         `/\      /                 ~-. _ .-~      /
remote:    \____(Oo)            *.   }            {                   /
remote:    (    (..)           .----~-.\        \-`                 .~
remote:    //___\\  \ DENIED!  ///.----..<        \             _ -~
remote:   //     \\                ///-._ _ _ _ _ _ _{^ - - - - ~
remote:
remote:
remote: OVERSIZED FILE
remote: This repository ("spellbook") is configured with a maximum individual file size limit, but you are pushing a change ("98d07af863e799509e7c3a639404d216f9fc79c7") which causes the size of a file ("magic_missile.txt") to exceed the limit. The commit makes the file 317 bytes long, but the limit for this repository is 1 bytes.
remote:
# Released cluster write lock.
To ssh://local.phacility.com/source/spellbook.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://epriestley@local.phacility.com/source/spellbook.git'
```

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: joshuaspence

Maniphest Tasks: T13216

Differential Revision: https://secure.phabricator.com/D19817
2018-11-20 08:04:17 -08:00
..
codex When destorying a repository, print a notification about removing the working copy 2017-08-01 08:57:39 -07:00
conduit Update Diffusion conduit text 2017-07-02 14:25:10 +00:00
config Move FontIcon calls to Icon 2016-01-28 08:48:45 -08:00
constants Simplify Create Repository page 2017-08-15 11:05:50 -07:00
customfield Move various other callsites away from callsigns 2016-01-04 06:54:42 -08:00
daemon Fix spelling 2017-10-09 10:48:04 -07:00
data Fix spelling 2017-10-09 10:48:04 -07:00
editor Remove pointless requireCapabilities() method from PhabricatorRepositoryEditor 2018-08-16 10:53:42 -07:00
engine Assign RepositoryIdentity objects to commits 2018-05-31 07:28:23 -07:00
graphcache Bail out of PhabricatorRepositoryGraphCache more aggressively after cache fills 2017-10-06 14:12:58 -07:00
mail Build separate mail for each recipient, honoring recipient access levels 2015-06-03 18:59:31 -07:00
management Update PhabricatorLiskDAO::chunkSQL() for new %Q semantics 2018-11-13 08:59:18 -08:00
phid Add an intracluster synchronization log for cluster repositories 2018-11-07 18:24:20 -08:00
query Fix all query warnings in "arc unit --everything" 2018-11-15 03:51:25 -08:00
response Accept and route VCS HTTP requests 2013-10-29 15:32:40 -07:00
search Add controllers/search/edit engine functionality to RepositoryIdentity 2018-05-31 07:03:25 -07:00
storage Support (but do not actually enable) a maximum file size limit for Git repositories 2018-11-20 08:04:17 -08:00
worker Fix all query warnings in "arc unit --everything" 2018-11-15 03:51:25 -08:00
xaction Assign RepositoryIdentity objects to commits 2018-05-31 07:28:23 -07:00