Commit Graph

102 Commits

Author SHA1 Message Date
Harvey Hunt
7358178f4a mononoke: Remove external sync logic
Summary:
Now that the `hg_external_sync` jobs are gone we can delete the code
in Mononoke that behaves differently when a sync job connects.

Reviewed By: StanislavGlebik

Differential Revision: D27500506

fbshipit-source-id: 443fb54577833dbf44ece6ae90a5f25ffed38cd5
2021-04-08 09:17:11 -07:00
Thomas Orozco
c934b67e5b mononoke: remove all trivial usage of async-unit
Summary:
I'd like to just get rid of that library since it's one more place where we
specify the Tokio version and that's a little annoying with the Tokio 1.x
update. Besides, this library is largely obsoleted by `#[fbinit::test]` and
`#[tokio::test]`.

Reviewed By: farnz

Differential Revision: D27619147

fbshipit-source-id: 4a316b81d882ea83c43bed05e873cabd2100b758
2021-04-07 07:26:57 -07:00
Mark Juggurnauth-Thomas
ee159ebecc test_repo_factory: use test factory for hooks and mapping tests
Summary: Use the test factory for existing hooks and mapping tests.

Reviewed By: StanislavGlebik

Differential Revision: D27169436

fbshipit-source-id: f814e462bb2244e117c83bd355042016f5bfde8e
2021-03-25 07:34:49 -07:00
Stanislau Hlebik
847a91291b mononoke: make it possible to allow moving a bookmark for a hipster group
Summary:
Currently we can only limit which users are allowed to move a bookmark by a
regex. We also want to allow specifying a hipster group.

Reviewed By: krallin

Differential Revision: D27156690

fbshipit-source-id: 99a5678a82f4c34ed2e57625361ba7cdb08ed839
2021-03-18 13:05:11 -07:00
Mateusz Kwapich
0c1567ee30 add invalid characters to the no_windows_filenames hook
Summary:
If a filename passes this hook it should be checkoutable on windows.

Unfortunately it's not the case now - we're missing the check for invalid
characters. Although this list might be redundant and some of chars might be
already banned by other hook let's make this hook a place for all
windows-specific filename checks.

Reviewed By: farnz

Differential Revision: D26979418

fbshipit-source-id: f1fa685b9e7e5413d8030d18bc083458b6a148e1
2021-03-11 13:38:50 -08:00
Mark Juggurnauth-Thomas
91358f3716 mononoke_types: use SortedVectorMap for BonsaiChangeset
Summary:
BonsaiChangesets are rarely mutated, and their maps are stored in sorted order,
so we can use `SortedVectorMap` to load them more efficiently.

In the cases where mutable maps of filechanges are needed, we can use `BTreeMap`
during the mutation and then convert them to `SortedVectorMap` to store them.

Reviewed By: mitrandir77

Differential Revision: D25615279

fbshipit-source-id: 796219c1130df5cb025952bb61002e8d2ae898f4
2021-03-11 04:28:43 -08:00
Aida Getoeva
62329eb258 mononoke/hooks: exempt opsfiles from reviewers check
Summary:
According to [verify_commit_msg.sh](https://www.internalfb.com/code/opsfiles/[db503bf9bbce17dddc362ea374056a2a77e4fdc9]/chef/cookbooks/other/fb_mercurial_server/files/default/scripts/hooks/bin/verify_commit_msg.sh) we want to exempt some of the commits from the verify Reviewed By hook.

This diff adds necessary checks: it uses file changes as a diff between two manifests for the full list of them.

This diff will land only after D26944289 because of changes made to the hook config.

Reviewed By: farnz

Differential Revision: D26927235

fbshipit-source-id: 44a43227caf3db4082724a4d421b9cf4b8800a1e
2021-03-10 08:44:13 -08:00
Andrey Chursin
0be8e8ce29 vfs: introduce AsyncVfs
Summary:
AsyncVfs provides async vfs interface.
It will be used in the native checkout instead of current use case that spawns blocking tokio tasks for VFS action

Reviewed By: quark-zju

Differential Revision: D26801250

fbshipit-source-id: bb26c4fc8acac82f4b55bb3f2f3964a6d0b64014
2021-03-05 21:47:51 -08:00
Thomas Orozco
2a803fc10d third-party/rust: update futures
Summary:
Those newer versions of Futures have compatibility improvements with Tokio,
notably:

- https://github.com/rust-lang/futures-rs/pull/2333
- https://github.com/rust-lang/futures-rs/pull/2358

Reviewed By: farnz

Differential Revision: D26778794

fbshipit-source-id: 5a9dc002083e5edfa5c614d8d2242e586a93fcf6
2021-03-04 06:42:55 -08:00
Aida Getoeva
fc0d0732c5 mononoke/validate-owners: implement secure-owners check
Summary: For the OWNERS files in `secure` and `core` we need to check that all the groups and users mentioned in the OWNERS are in the secure owners group.

Reviewed By: StanislavGlebik

Differential Revision: D26761772

fbshipit-source-id: 02ad2bc45c82792e51702cd4d8d092557c76c015
2021-03-03 12:40:07 -08:00
Thomas Orozco
ef7045e818 common/rust: use fbinit-tokio
Summary:
This diffs add a layer of indirection between fbinit and tokio, thus allowing
us to use fbinit with tokio 0.2 or tokio 1.x.

The way this works is that you specify the Tokio you want by adding it as an
extra dependency alongside `fbinit` in your `TARGETS` (before this, you had to
always include `tokio-02`).

If you use `fbinit-tokio`, then `#[fbinit::main]` and `#[fbinit::test]` get you
a Tokio 1.x runtime, whereas if you use `fbinit-tokio-02`, you get a Tokio 0.2
runtime.

This diff is big, because it needs to change all the TARGETS that reference
this in the same diff that introduces the mechanism. I also didn't produce it
by hand.

Instead, I scripted the transformation using this script: P242773846

I then ran it using:

```
{ hg grep -l "fbinit::test"; hg grep -l "fbinit::main"  } | \
  sort | \
  uniq | \
  xargs ~/codemod/codemod.py \
&&  yes | arc lint \
&& common/rust/cargo_from_buck/bin/autocargo
```

Finally, I grabbed the files returned by `hg grep`, then fed them to:

```
arc lint-rust --paths-from ~/files2 --apply-patches --take RUSTFIXDEPS
```

(I had to modify the file list a bit: notably I removed stuff from scripts/ because
some of that causes Buck to crash when running lint-rust, and I also had to add
fbcode/ as a prefix everywhere).

Reviewed By: mitrandir77

Differential Revision: D26754757

fbshipit-source-id: 326b1c4efc9a57ea89db9b1d390677bcd2ab985e
2021-03-03 04:09:15 -08:00
Lukas Piatkowski
edb679f785 autocargo v2: rollout and replace v1 in all use-cases
Summary:
This diff rollouts V2 of autocargo in an atomic way so there are quite a few things done here.

Arc lint support:

V1 used to be part of the default fbsource `arc lint` engine, but since V2 calls buck it must live in a separate lint engine. So this diff:
- Adds running `autocargo` as part of `arc lint-rust`

Mergedriver update:

- Mergedriver used in resolving conflicts on commits is now pointing to V2
- It handles files in `public_autocargo/` directories in addition to the ones containig generation preamble

Including regeneration results of running `common/rust/cargo_from_buck/bin/autocargo`. All the differences are accounted for:

- Some sections and attributes are removed as they can be autodiscovered by Cargo (like `lib.path = "src/lib.rs"` or empty [lib] section)
- "readme" attribute is properly defined as relative to Cargo.toml location rather than as hardcoded string
- "unittest = false" on a Buck rule propagates as "test = false; doctest = false" to Cargo
- "rusqlite" is not special-cased anymore, so the "budled" feature will have to be enabled using custom configuration if required by the project (for rust-shed in order to not break windows builds a default feature section was added)
- Files generated from thrift_library rules that do not support "rust" language are removed
- Custom .bzl rules that create rust artifacts (like `rust_python_extension`) are no longer ignored

Others:

- Changed `bin/cargo-autocargo` to be a wrapper for calling V2 via `cargo autocargo`
- Updated following files to use V2:
  - `common/rust/tools/reindeer/version-bump`
  - `remote_execution/rust/setup.sh`
- Removed few files from V1 that would otherwise interfere with V2 automatic regeneration/linting/testing

Reviewed By: zertosh

Differential Revision: D26728789

fbshipit-source-id: d1454e7ce658a2d3194704f8d77b12d688ec3e64
2021-03-02 06:43:29 -08:00
Lukas Piatkowski
f317302b0f autocargo v1: reformating of oss-dependencies, workspace and patch sections and thrift files to match v2
Summary:
For dependencies V2 puts "version" as the first attribute of dependency or just after "package" if present.
Workspace section is after patch section in V2 and since V2 autoformats patch section then the third-party/rust/Cargo.toml manual entries had to be formatted manually since V1 takes it as it is.
The thrift files are to have "generated by autocargo" and not only "generated" on their first line. This diff also removes some previously generated thrift files that have been incorrectly left when the corresponding Cargo.toml was removed.

Reviewed By: ikostia

Differential Revision: D26618363

fbshipit-source-id: c45d296074f5b0319bba975f3cb0240119729c92
2021-02-25 15:10:56 -08:00
Stefan Filip
84017abe21 segmented_changelog: update OnDemandUpdateDag to have smaller critical sections
Summary:
The on demand update code we have is the most basic logic that we could have.
The main problem is that it has long and redundant write locks. This change
reduces the write lock strictly to the section that has to update the in memory
IdDag.

Updating the Dag has 3 phases:
* loading the data that is required for the update;
* updating the IdMap;
* updating the IdDag;

The Dag can function well for serving requests as long as the commits involved
have been built so we want to have easy read access to both the IdMap and the
IdDag. The IdMap is a very simple structure and because it's described as an
Arc<dyn IdMap> we push the update locking logic to the storage.  The IdDag is a
complicated structure that we ask to update itself. Those functions take
mutable references. Updating the storage of the iddag to hide the complexities
of locking is more difficult. We deal with the IdDag directly by wrapping it in
a RwLock. The RwLock allows for easy read access which we expect to be the
predominant access pattern.

Updates to the dag are not completely stable so racing updates can have
conflicting results. In case of conflics one of the update processes would have
to restart. It's easier to reason about the process if we just allow one
"thread" to start an update process. The update process is locked by a sync
mutex. The "threads" that fail the race to update are asked to wait until the
ongoing update is complete. The waiters will poll on a shared future that
tracks the ongoing dag update. After the update is complete the waiters will go
back to checking if the data they have is available in the dag. It is possible
that the dag is updated in between determining that the an update is needed and
acquiring the ongoing_update lock. This is fine because the update building
process checks the state of dag before the dag and updates only what is
necessary if necessary.

Reviewed By: krallin

Differential Revision: D26508430

fbshipit-source-id: cd3bceed7e0ffb00aee64433816b5a23c0508d3c
2021-02-22 18:17:21 -08:00
Thomas Orozco
097e4ad00c mononoke: remove tokio-compat (i.e. use tokio 0.2 exclusively)
Summary:
The earlier diffs in this stack have removed all our dependencies on the Tokio
0.1 runtime environment (so, basically, `tokio-executor` and `tokio-timer`), so
we don't need this anymore.

We do still have some deps on `tokio-io`, but this is just traits + helpers,
so this doesn't actually prevent us from removing the 0.1 runtime!

Note that we still have a few transitive dependencies on Tokio 0.1:

- async-unit uses tokio-compat
- hg depends on tokio-compat too, and we depend on it in tests

This isn't the end of the world though, we can live with that :)

Reviewed By: ahornby

Differential Revision: D26544410

fbshipit-source-id: 24789be2402c3f48220dcaad110e8246ef02ecd8
2021-02-22 09:22:42 -08:00
Lukas Piatkowski
cd0b6d50e2 autocargo v1: changes to match autocargo v2 generation results.
Summary:
The changes (and fixes) needed were:
- Ignore rules that are not rust_library or thrift_library (previously only ignore rust_bindgen_library, so that binary and test dependencies were incorrectly added to Cargo.toml)
- Thrift package name to match escaping logic of `tools/build_defs/fbcode_macros/build_defs/lib/thrift/rust.bzl`
- Rearrange some attributes, like features, authors, edition etc.
- Authors to use " instead of '
- Features to be sorted
- Sort all dependencies as one instead of grouping third party and fbcode dependencies together
- Manually format certain entries from third-party/rust/Cargo.toml, since V2 formats third party dependency entries and V1 just takes them as is.

Reviewed By: zertosh

Differential Revision: D26544150

fbshipit-source-id: 19d98985bd6c3ac901ad40cff38ee1ced547e8eb
2021-02-19 11:03:55 -08:00
Aida Getoeva
bc392c1dfa mononoke/hooks: extend file content manager to search for last updates
Summary:
OWNERS hook sometimes needs to know the most recent changes made to the OWNERS files. So the user, who was last to change the OWNERS file, can change it again.

This diffs extends `FileContentManager` trait to have a new method `recent_changes`. It derives unode manifest for the given bookmark, finds given paths and gets linknodes. For the linknodes it derives `ChangesetInfo` which is a lightweight version of the bonsai changesets, they contain all the metadata, but don't have a set file changes.

We use unodes here instead of hg manifests, because hg manifests don't have correct linknodes.

Reviewed By: StanislavGlebik

Differential Revision: D26468603

fbshipit-source-id: 78dd0a4e51bee6228de1296eafe7ffa393df2fbe
2021-02-18 18:46:26 -08:00
Lukas Piatkowski
87ddbe2f74 autocargo v1: update autocargo field format to allow transition to autocargo v2
Summary:
Autocargo V2 will use a more structured format for autocargo field
with the help of `cargo_toml` crate it will be easy to deserialize and handle
it.

Also the "include" field is apparently obsolete as it is used for cargo-publish (see https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields). From what I know this might be often wrong, especially if someone tries to publish a package from fbcode, then the private facebook folders might be shipped. Lets just not set it and in the new system one will be able to set it explicitly via autocargo parameter on a rule.

Reviewed By: ahornby

Differential Revision: D26339606

fbshipit-source-id: 510a01a4dd80b3efe58a14553b752009d516d651
2021-02-12 23:28:25 -08:00
Thomas Orozco
db7f9fe76b third-party/rust: update Hyper
Summary:
johansglock pointed out that Hyper is affected by CVE-2021-21299. Let's update
to a fixed version.

Reviewed By: farnz

Differential Revision: D26313854

fbshipit-source-id: 4db04d3044fb9f22a037bda0a88a5314f62f9dfc
2021-02-12 04:56:24 -08:00
Thomas Orozco
2a21e4fb17 third-party/rust: update Tokio to 0.2.25 + add a patch to disable coop scheduling
Summary:
See the patch & motivation here:

818f943db3

Reviewed By: StanislavGlebik

Differential Revision: D26399890

fbshipit-source-id: e184a3f6c1dd03cb4cdb7ea18073c3392d7ce355
2021-02-12 04:56:23 -08:00
Aida Getoeva
c104a929f3 mononoke/hooks: fetch owners files
Summary:
This diff introduces abstractions for the OWNERS files and the rules. For now rules don't have any acl checkers and just store the parsed user and group names as a lists of strings.

Now we find and fetch all the possible owners files using `FileContentFetcher` new API.

Reviewed By: StanislavGlebik

Differential Revision: D25379329

fbshipit-source-id: 0933ef4e5e960102b46af9ed2f3e0b12d9761000
2021-02-10 01:48:52 -08:00
Aida Getoeva
6c4de32589 mononoke/hooks: rename file content fetcher into manager
Summary: The `FileContentFetcher` trait with the new API like `find_content` or `file_changes` looks more like a "manager" rather than a "fetcher".

Reviewed By: StanislavGlebik

Differential Revision: D26040535

fbshipit-source-id: 20ab3b0730e4a2b1cbe2991c3c13a9d8a8ec8f35
2021-02-10 01:48:52 -08:00
Thomas Orozco
c9408fb886 mononoke/hooks: don't enable acl checker when you don't need it
Summary: Loading an Acl Checker is expensive. Don't do it given we don't use it.

Reviewed By: HarveyHunt

Differential Revision: D26337699

fbshipit-source-id: bc48ac44b3301db5bd03a5d2006b92912b7e6fd0
2021-02-09 07:44:59 -08:00
Aida Getoeva
562f00cfd7 mononoke/hooks: extend file fetcher to get file changes
Summary:
This diff adds method to FileContentFetcher to get a file changes between two changesets using hg manifests. The method returns a list of file changes, where added/changed paths contain content ids.

The API is needed for Owners files hook.

Reviewed By: StanislavGlebik

Differential Revision: D26040536

fbshipit-source-id: 816194a494f0c77e8ea9aef729fd6161eed904ff
2021-02-08 10:48:22 -08:00
Aida Getoeva
99b9742872 mononoke/hooks: extend file fetcher to find files
Summary:
Owners file hook requires access to the files in master branch.
This diff extends `FileContentFetcher` to have API for finding files in the master commit. The methods are implemented for the blobrepo. They derive unode manifest for the master bookmark and search given file paths in the manifest, returning list of file content ids.

Reviewed By: StanislavGlebik

Differential Revision: D24936674

fbshipit-source-id: c63931c073b6148972bc8e81126f7c4786db920a
2021-02-08 10:48:22 -08:00
Thomas Orozco
ad5dc2d59d third-party/rust: hyper-02: update to 0.13.9
Summary:
Just a minor version update. I'd like to add a patch on top of this for a PR
that hasn't been merged yet, but updating to the underlying released version
first will make the diff clearer.

Reviewed By: ahornby

Differential Revision: D26047997

fbshipit-source-id: 91856f645ec3aaaf4fbf256a23c7e8d4db0f6b37
2021-01-26 07:21:28 -08:00
Daniel Xu
5715e58fce Add version specificiation to internal dependencies
Summary:
Lots of generated code in this diff. Only code change was in
`common/rust/cargo_from_buck/lib/cargo_generator.py`.

Path/git-only dependencies (ie `mydep = { path = "../foo/bar" }`) are not
publishable to crates.io. However, we are allowed to specify both a path/git
_and_ a version. When building locally, the path/git is chosen. When publishing,
the version on crates.io is chosen.

See https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#multiple-locations .

Note that I understand that not all autocargo projects are published on crates.io (yet).
The point of this diff is to allow projects to slowly start getting uploaded.
The end goal is autocargo generated `Cargo.toml`s that can be `cargo publish`ed
without further modification.

Reviewed By: lukaspiatkowski

Differential Revision: D26028982

fbshipit-source-id: f7b4c9d4f4dd004727202bd98ab10e201a21e88c
2021-01-25 22:10:24 -08:00
Thomas Orozco
4dd3461824 third-party/rust: update Tokio 0.2.x to 0.2.24 & futures 1.x to 1.30
Summary:
When we tried to update to Tokio 0.2.14, we hit lots of hangs. Those were due
to incompatibilities between Tokio 0.2.14 and Futures 1.29. We fixed some of
the bugs (and others had been fixed and were pending a release), and Futures
1.30 have now been released, which unblocks our update.

This diff updates Tokio accordingly (the previous diff in the stack fixes an
incompatibility).

The underlying motivation here is to ease the transition to Tokio 1.0.
Ultimately we'll be pulling in those changes one or way or another, so let's
get started on this incremental first step.

Reviewed By: farnz

Differential Revision: D25952428

fbshipit-source-id: b753195a1ffb404e0b0975eb7002d6d67ba100c2
2021-01-25 08:06:55 -08:00
Radu Szasz
5fb5d23ec8 Make tokio-0.2 include test-util feature
Summary:
This feature is useful for testing time-dependent stuff (e.g. it
allows you to stop/forward time). It's already included in the buck build.

Reviewed By: SkyterX

Differential Revision: D25946732

fbshipit-source-id: 5e7b69967a45e6deaddaac34ba78b42d2f2ad90e
2021-01-18 10:38:08 -08:00
Daniel Xu
1e78d023e7 Update regex to v1.4.2
Summary: Update so libbpf-cargo doens't need to downgrade regex version.

Reviewed By: kevin-vigor

Differential Revision: D25719327

fbshipit-source-id: 5781871a359f744e2701a34df1931f0c37958c27
2020-12-29 22:59:52 -08:00
Saurabh Singh
0f465f7dc9 hooks: show the size of the large commit being blocked
Summary:
This is useful data to see how much we are over the limit. I noticed
the missing data while resolving
https://fb.workplace.com/groups/scm/permalink/3450652774984318/ as the oncall.

Reviewed By: StanislavGlebik

Differential Revision: D25414427

fbshipit-source-id: ec4bbca9c21a4bf0e675ec1cd82e4e703cd88631
2020-12-09 16:44:41 -08:00
Stefan Filip
2193b84b43 autocargo: regen
Summary: Regen autocargo

Reviewed By: quark-zju

Differential Revision: D25409963

fbshipit-source-id: 7dbbe420aeb30248bf43d3a96a9aa6a47bb2b0be
2020-12-08 18:30:24 -08:00
Kostia Balytskyi
e4dab84619 scuba: turn ScubaSampleBuilderExt into a wrapper struct
Summary:
This diff prepares the Mononoke codebase for composition-based extendability of
`ScubaSampleBuilder`. Specifically, in the near future I will add:
- new methods for verbose scuba logging
- new data field (`ObservabilityContext`) to check if verbose logging should
  be enabled or disabled

The higher-level goal here is to be able to enable/disable verbose Scuba
logging (either overall or for certain slices of logs, like for a certain
session id) in real time, without restarting Mononoke. To do so, I plan to
expose the aforementioned verbose logging methods, which will run a check
against the stored `ObservabilityContext` and make a decision of whether the
logging is enabled or not. `ObservabilityContext` will of course hide
implementation details from the renamed `ScubaSampleBuilderExt`, and just provide a yes/no
answer based on the current config and sample fields.

At the moment this should be a completely harmless change.

Reviewed By: krallin

Differential Revision: D25211089

fbshipit-source-id: ea03dda82fadb7fc91a2433e12e220582ede5fb8
2020-11-30 21:26:24 -08:00
Lukas Piatkowski
fa1a195fd0 mononoke/blobstore: pass CoreContext via borrowed instead of owned value
Summary: Follow up after removing 'static from blobstore.

Reviewed By: StanislavGlebik

Differential Revision: D25182106

fbshipit-source-id: e13a7a31d71b4674425123268e655ae66127f1b7
2020-11-27 03:31:07 -08:00
Kostia Balytskyi
c85fe51f5f hooks: allow two types of bypasses for the same hook
Summary:
There seem to be legitimate cases when we want to have both bypass mechanisms available: via the commit message and via the pushvar. The need to be able to use a commit message arises from the fact that engineers rarely have access to push CLI, so they cannot use pushvars. Still, pushvars are useful if we want to push an existing commit without any changes to its message.

NB. Since I wanted to make `HookBypass` a multi-option, I had to change it from `enum` to `struct`. If I left fields `pub` in that struct (the way it's commonly done in `metaconfig`, I would've allowed `HookBypass` instances with both options `None`. This is not a big deal, but is a bit ugly as we already store `Option<HookBypass>` instead, so it's better if `Some(hook_bypass)` symbolizes that there indeed is some way to bypass the hook. So I opted in for constructors, getters and private fields.

Reviewed By: StanislavGlebik

Differential Revision: D25000578

fbshipit-source-id: ad13076c9690ee8d45fc4a93e32a6026ff5bdd09
2020-11-17 06:02:30 -08:00
Stanislau Hlebik
e7fe9e4ea9 mononoke: do not allow too big commits to be landed
Reviewed By: krallin

Differential Revision: D24730106

fbshipit-source-id: e2b116c437a557f1b795c3b07eb124b8dd1a3ef8
2020-11-06 11:24:19 -08:00
Thomas Orozco
184310158b mononoke/filestore: update fetch external API to 0.3 futures
Summary:
Like it says in the title. This required quite a lot of changes at callsites,
as you'd expect.

Reviewed By: StanislavGlebik

Differential Revision: D24731299

fbshipit-source-id: e58447e88dcc3ba1ab3c951f87f7042e2b03eb2c
2020-11-06 07:26:03 -08:00
Thomas Orozco
40e8cab560 mononoke/filestore: update metadata to futures 0.3
Summary:
This updates the metadata APIs in the filestore to futures 0.3 & async / await.
This changes the external API of the filestore, so there's quite a bit of churn
outside of that module.

Reviewed By: markbt

Differential Revision: D24727255

fbshipit-source-id: 59833f185abd6ab9c609c6bcc22ca88ada6f1b42
2020-11-06 07:26:03 -08:00
Xavier Deguillard
c5480fdf6f hooks: forbid windows reserved names in the repos
Summary:
The root cause for S199754 was a file named "con.rs" was checked in onto the
repo. Since this is a reserved filename on Windows, this broke all Windows
users having it in their sparse profiles.

The rules for reserved names are defined as such by Microsoft:

"CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9,
LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these
names followed immediately by an extension; for example, NUL.txt is not
recommended. For more information, see Namespaces."

Of course, since the filesystem is case insensitive, these can have any casing.

Reviewed By: krallin

Differential Revision: D24453528

fbshipit-source-id: 389f15e2b1a88e3c1e8721fb7868616acabebc64
2020-11-05 19:24:04 -08:00
Jan Mazur
8152776a35 bypassing hooks for members of scm
Summary: Members of `scm` hipster group will be able to push to mononoke bypassing hooks when `BYPASS_ALL_HOOKS` pushvar is passed.

Reviewed By: krallin

Differential Revision: D24477468

fbshipit-source-id: ac910bf27e5510e1975c4a7cd0bfeff5216da70e
2020-10-29 10:14:25 -07:00
Mateusz Kwapich
cd27efe09c make @nocommit hook stricter
Reviewed By: admdikramr

Differential Revision: D24590666

fbshipit-source-id: 7a56760cfb3381d5fe84b67a9708e0dda377c31d
2020-10-29 03:43:48 -07:00
Jan Mazur
d7cf79cf5a print regex when rejecting a file
Summary: It will be much more convenient for end user to know why certain limit is enforced.

Reviewed By: krallin

Differential Revision: D24364473

fbshipit-source-id: ad86384f7f7a246bc3735028339cfd54a1d0254a
2020-10-19 03:27:50 -07:00
Jan Mazur
274d46b7a0 change limit_filesize hook to operate fully on regexes and per-regex limits
Summary: See summary in D24161361

Reviewed By: krallin

Differential Revision: D24190905

fbshipit-source-id: 75311425ba4296925d761f89a2d24cbbb5bebd03
2020-10-16 07:34:43 -07:00
Kostia Balytskyi
7af104b330 hooks: bypass more hooks for push-redirected pushes
Summary:
Until we have the same standards for the native and push-redirected pushes,
these need to be automatically bypassed.

Reviewed By: krallin

Differential Revision: D24357372

fbshipit-source-id: f85459145f6a5217c07445d7017f3b11ed1284a7
2020-10-16 04:25:56 -07:00
Kostia Balytskyi
ed21f74ceb hooks: cleanup weird conversions
Summary:
Likely `MPath` constructor got more clever since this was written. In any case
I am just happy that it builds.

Reviewed By: farnz

Differential Revision: D24278551

fbshipit-source-id: 2378a43bd01b1826b7f81d294a035053fba5322f
2020-10-13 15:25:39 -07:00
Kostia Balytskyi
49c9c3e4f7 hooks: deny_files act upon cross-repo-push-origin
Summary: For the purposes of megarepo, we need to treat certain paths differently depending on whether the push is native to a large repo, or is push-redirected from a small repo. Let's add a separate patterns list to the `deny_files` hook. Of course, we can also add a list, specific for push-redirected pushes, but it seems unneeded atm.

Reviewed By: StanislavGlebik

Differential Revision: D24278409

fbshipit-source-id: 9fd815940bb656ceac6ab234f3a0647a5c57db06
2020-10-13 10:42:40 -07:00
Kostia Balytskyi
660937cf9d hooks: be aware of native vs push-redirected pushes
Summary:
This change adds some wiring to allow the hooks to treat native vs push-redirected pushes differently. This is needed because `deny-files` needs to block native pushes to `.ovrsource-rest` and `arvr-legacy`, while it needs to allow push-redirection into these directories.

The plan further is to change the actual hook body for `deny_files` to have different handling of the two cases.

Reviewed By: StanislavGlebik

Differential Revision: D24257454

fbshipit-source-id: 2f5931149115210aeeeebb3294a6512effd36350
2020-10-13 05:46:56 -07:00
Kostia Balytskyi
c02ee1b1d1 hooks: allow deletion of any files in no_insecure_filenames
Reviewed By: StanislavGlebik

Differential Revision: D24190517

fbshipit-source-id: d26a144596f0bd316a9e6b1e7000efc31b93d049
2020-10-08 05:03:37 -07:00
Kostia Balytskyi
2ea25308ab commit_rewriting: use is_empty() where possible
Summary: `clippy` often complains about the use of `.len() != 0`, `.len() > 0` or `.len() == 0`and proposes to use `.is_empty()` instead. This diff does that across Mononoke.

Reviewed By: aslpavel

Differential Revision: D24099427

fbshipit-source-id: 1bba2f958485b7efb3f41bf3eae820879c92b0e5
2020-10-04 10:03:42 -07:00
Jan Mazur
88bf94aacb move interngraph token from disk to keychain service
Summary:
Interngraph token is already stored within keychain service. We should make use of that.

I'll need to remove related config option in convigerator in a separate diff.

Reviewed By: krallin

Differential Revision: D24015463

fbshipit-source-id: 9e8246e2cc252f0c42669140de7b50410a15709c
2020-10-02 06:56:49 -07:00