Commit Graph

654 Commits

Author SHA1 Message Date
Mark Severson
3fcdb9b185 refactor(general): avoid using empty master keys (#3835)
Previously, empty master keys were passed to the underlying
cryptographic primitives (HKDF, AEAD, etc.).

While this worked because the authentication mechanisms returned an
error, it's best to avoid passing empty master keys to these primitives
in the first place. This refactor avoids passing empty master keys and
enforces this via an assertion in the key derivation function.
2024-05-01 14:50:01 -07:00
Julio López
ad06bb20b1 refactor(general): remove ability to enable compaction on index load (#3834)
Cleanup.

- Fixes: #3638
- #3639
2024-05-01 14:33:46 -07:00
Julio López
065e0adbfd refactor(general): make key derivers available in tests (#3826)
- Re-introduces the **insecure**, lightweight key deriver for
  testing **only**.
- Makes `scrypt` and `pbkdf2` derivers available in tests as well.
2024-04-30 17:21:11 -07:00
Julio López
ca1962f6e4 refactor(general): user password hashing and key derivation helpers (#3821)
Code movement and simplification, no functional changes.

Objectives:
- Allow callers specifying the needed key (or hash) size, instead of
hard-coding it in the registered PBK derivers. Conceptually, the caller
needs to specify the key size, since that is a requirement of the
(encryption) algorithm being used in the caller. Now, the code changes
here do not result in any functional changes since the key size is
always 32 bytes.
- Remove a global definition for the default PB key deriver to use.
Instead, each of the 3 use case sets the default value.

Changes:
- `crypto.DeriveKeyFromPassword` now takes a key size.
- Adds new constants for the key sizes at the callers.
- Removes the global `crypto.MasterKeySize` const.
- Removes the global `crypto.DefaultKeyDerivationAlgorithm` const.
- Adds const for the default derivation algorithms for each use case.
- Adds a const for the salt length in the `internal/user` package, to ensure
  the same salt length is used in both hash versions.
- Unexports various functions, variables and constants in the `internal/crypto`
  & `internal/user` packages.
- Renames various constants for consistency.
- Removes unused functions and symbols.
- Renames files to be consistent and better reflect the structure of the code.
- Adds a couple of tests to ensure the const values are in sync and supported.
- Fixes a couple of typos

Followups to:
- #3725
- #3770
- #3779
- #3799
- #3816

The individual commits show the code transformations to simplify the
review of the changes.
2024-04-26 23:30:56 -07:00
Julio López
2db8b20ed9 chore(general): rename files for consistency (#3825) 2024-04-26 14:47:36 -07:00
Sirish Bathina
1e98511c2e feat(general): key derivation algorithm for cache encryption (#3799)
Add an option to select the password-based key derivation algorithm
for the local cache encryption key when connecting to a kopia
repository server.
2024-04-25 17:45:12 -07:00
Sirish Bathina
02463ab118 feat(general): user profile hashing version to algorithm translation (#3816)
Reverts to using the `PasswordHashVersion` in the user profile.
Adds a simple mechanism for translating between password hash
version and the corresponding password hashing algorithm (key
derivation algorithm).
2024-04-24 17:50:26 -07:00
Julio López
17c3a8d4de refactor(general): include parameters in pbkdf2 instantiation (#3811)
Use `pbkdf2-sha256-600000` as the name to be consistent with the scrypt
instantiation.

The format is `pbkdf2-<hash_type>-<number_of_iterations>`
2024-04-19 15:50:45 -07:00
Julio López
ff9f6a8325 refactor(general): change default number of iterations for PBKDF2 (#3810)
Use the value recommended by NIST
2024-04-19 15:27:38 -07:00
Jarek Kowalski
211e28c98c chore(repository): BREAKING CHANGE remove support for HTTP-based repository API (#3745)
Remove support for HTTP-based repository API
2024-04-17 16:23:58 -07:00
Jarek Kowalski
b55d5b474c refactor(repository): refactored internal index read API to reduce memory allocations (#3754)
* refactor(repository): refactored internal index read API to reduce memory allocations

* fixed stress test flake, improved debuggability

* fixed spurious checklocks failures

* post-merge fixes

* pr feedback
2024-04-12 22:59:11 -07:00
Sirish Bathina
5fa39fe5eb feat(general): User_profile_add_set cli changes (#3770)
* User profile add set cli changes

* Add additional test

* get salt length from key deriver

* Fixes for failing tests

* after shikhars review

* lint fixes
2024-04-10 17:56:13 -07:00
Jarek Kowalski
123927d573 fix(server): fixed deadlock between server and scheduler during shutdown (#3782) 2024-04-09 22:37:50 -07:00
Jarek Kowalski
09415e0c7d chore(ci): upgraded to go 1.22 (#3746)
Upgrades go to 1.22 and switches to new-style for loops

---------

Co-authored-by: Julio López <1953782+julio-lopez@users.noreply.github.com>
2024-04-08 09:52:47 -07:00
lvyaoting
67f87a5450 chore(general): fix function names in comment (#3786)
Signed-off-by: lvyaoting <lvyaoting@outlook.com>
2024-04-07 21:33:33 -07:00
Christoph Anderson
db5d868b5f feat(ui): Add language support for kopiaUI (#3768)
* Add multi-language support

* Adding a guidline to outline the localisation process.

* Moved doc to separate pr

---------

Co-authored-by: lupusA <lupuapps@gmail.com>
2024-04-06 05:10:11 +00:00
Aaron Alpar
2994179025 comment fixes (#3775) 2024-04-04 13:56:39 -07:00
Matthieu MOREL
5c85ca6bb0 refactor(deps): migrate from go.uber.org/multierr to standard errors (#3761)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-04-01 23:16:20 -07:00
Aaron Alpar
a4260e0185 fix(providers): Reduce memory allocation (gc thrash) (#3695)
Avoid minio allocations by implementing `ReadAt` function.
This change causes Minio libraries to reduce memory allocations.
Specifically, buffer allocations for S3 upload.
Add tests for new functionality.

---------

Co-authored-by: Shikhar Mall <shikhar.mall@veeam.com>
Co-authored-by: Nick <nick@kasten.io>
2024-04-01 15:10:27 -07:00
Julio López
e600c15b6b fix(general): disable writes on index loads (#3646)
Change default 'allowWritesOnIndexLoad' to false when env var is unset
Add TestNoEpochAdvanceOnIndexRead

Ref:
- Followup to #3645
- Avoid index (epoch) cleanup and compaction during index reads #3638
- Make "read" commands/operations really read-only.  #3639
2024-03-31 22:27:49 -07:00
Julio López
522209369c refactor(test): explicitly advance epoch in TestMaybeCompactSingleEpoch_CompactionError (#3755)
Ref:
- #3638
2024-03-27 12:49:53 -07:00
Jarek Kowalski
7278f570e2 chore(ci): upgraded linter to 1.57.1 (#3753) 2024-03-25 22:20:38 -07:00
Julio López
fdb6d3c097 refactor(general): add epoch.Manager.MaybeGenerateRangeCheckpoint (#3727)
* epoch manager: factor out getRangeToCompact
* epoch manager: add epoch.Manager.MaybeGenerateRangeCheckpoint
* test epoch.Manager.MaybeGenerateRangeCheckpoint
2024-03-22 15:29:11 -07:00
Julio López
f8352275ba refactor(general): add epoch.Manager.CleanupMarkers (#3726)
Includes tests for CleanupMarkers
2024-03-19 18:35:29 -07:00
Julio López
6236ff7fba refactor(general): add epoch.Manager.MaybeCompactSingleEpoch (#3728)
Add:
- epoch.Manager.MaybeCompactSingleEpoch
- getCompactedEpochRange helper
- oldestUncompactedEpoch helper
- TestOldestUncompactedEpoch
- Tests for MaybeCompactSingleEpoch

Ref:
- Subset and dependency of #3651
- Depends on #3735
- Avoid index (epoch) cleanup and compaction during index reads #3638
- Make "read" commands/operations really read-only.  #3639
2024-03-19 17:46:45 -07:00
Julio López
316356a031 refactor(general): closedIntRange (#3735)
Refactoring for the original implementation with intRange and
getKeyRange from closed-open ranges [lo, hi) to closed ranges: [lo, hi].
The primary motivation is for consistency with the implementation
of epoch.RangeMetadata in the same package, and thus avoid
confusion and reduce cognitive load.

Changes:

- adds a getContiguousKeyRange wrapper that checks for contiguity.
- getKeyRange simply returns a range with minimum and maximum
  values for the keys in the map.
- changes the range implementation from closed-open ranges [lo, hi)
   to closed ranges: [lo, hi] where both lo and hi are included in the range.
- Additional unit tests are included.
- renames intRange to closedIntRange to reflect new functionality.

Ref:
- Follow up refactor(general): add epoch.getKeyRange helper #3721
- Needed for refactor(general): add epoch.Manager.MaybeCompactSingleEpoch #3728
- Avoid index (epoch) cleanup and compaction during index reads #3638
2024-03-18 22:58:16 -07:00
Sirish Bathina
4ea6cf98d1 update min salt size to 16 (#3732) 2024-03-13 15:02:33 -07:00
Nick
8647f71299 fix(cli): Output error msg returned by API server payload when possible (#3724)
Updates unit test expected error output
2024-03-13 18:29:50 +00:00
Sirish Bathina
ddcdfdb55a changes for switching key derivation (#3725) 2024-03-13 00:34:46 +00:00
Julio López
4a06623eb6 refactor(general): add clarification comment (#3723)
Followup to #3721

Co-authored-by: Nick <nick@kasten.io>
2024-03-12 11:52:25 -07:00
Julio López
e143c71e6d refactor(general): add epoch.getKeyRange helper (#3721)
Extracted from #3651.

Thanks to @plar and @redgoat650 for the suggestions.

Ref:

- #3603
- #3645
- #3638
- #3639
2024-03-12 11:05:50 -07:00
Julio López
e347710611 nit: fix comment (#3722) 2024-03-11 22:23:56 -07:00
Jarek Kowalski
fb8d9c3bf8 chore(deps): removed direct deprecated protobuf dependency (#3720) 2024-03-11 21:47:14 -07:00
Jarek Kowalski
29cd545c33 chore(ci): upgrade linter to 1.56.2 (#3714) 2024-03-09 10:39:11 -08:00
Nick
f5efb670b9 fix(server): Return internal server errors for Content Get errors (#3713) 2024-03-08 07:38:16 -08:00
Julio López
be49fcd42b refactor(general): add epoch.Manager.MaybeAdvanceEpoch helper (#3709)
Add
- TestMabyeAdvanceEpoch
- TestMabyeAdvanceEpoch_Empty
- TestMaybeAdvanceEpoch_Error
- TestMaybeAdvanceEpoch_GetParametersError

Ref:
- #3638
- #3645
- #3651
2024-03-06 17:12:49 -08:00
Jarek Kowalski
3e21bb5973 feat(repository): added metrics timeseries computation (#3678)
* feat(repository): added metrics timeseries computation

This code is not used anywhere yet, will be used for reporting over
repository metrics.

* fixed checklocks

* Update internal/metrics/metrics_timeseries.go

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>

---------

Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
2024-03-02 22:34:08 -08:00
Aaron Alpar
d034a37682 feat(cli): 1B: PPROF extensions: load profile config (#3668)
Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
2024-02-27 12:30:14 -08:00
Julio López
8d9e8d580e test(general): fix TestIndexEpochManager_CompactionAlwaysFails (#3677) 2024-02-23 20:42:39 -08:00
Aaron Alpar
58ea857f14 rename env var (#3669) 2024-02-21 13:24:54 -08:00
Jarek Kowalski
d0fc1e03c4 fix(server): do not make blocking calls inside server status API (#3666)
also reduce global server lock scope
2024-02-21 12:34:16 -08:00
Aaron Alpar
a726f11a04 feat(cli): 1a: PPROF extensions: PEM dump (#3665)
* c1a commit

* fixup package comment

* happy lint
2024-02-21 00:07:37 +00:00
Jarek Kowalski
524ffaf4b8 refactor(repository): added context to potentially blocking repository methods (#3654)
Primarily for wiring a context.Context to a call to content.Manager.refresh,
which was using a detached context.
2024-02-20 14:48:23 -08:00
Julio López
06ff37fa63 refactor(general): allow disabling writes on index index loads (#3645)
Conditionally disables epoch index maintenance operations when loading indexes.
This prevents (potentially expensive) cleanup write operations on the index
read path.
The behavior is controlled via the `epoch.Manager.allowCleanupWritesOnIndexLoad`
field, which can be temporarily overridden via an environment variable.
This override mechanism will be removed in the near future.

Refs:

- #3174
- #3224
- #3225
- #3638
- #3639
2024-02-16 14:59:06 -08:00
Julio López
1892a9f1d9 refactor(general): move index cleanup out to refreshAttempt (#3603)
Refactor: move index compaction and cleanup out of refreshAttemptLocked

Introduces an `allowWritesOnLoadHelper` to check whether or not writes
can be performed when loading the indexes. Currently this is only
a function of whether the storage is in read-only mode. In the near
future, an explicit flag will be added to control this behavior.

Fix epoch manager: avoid single-epoch compaction when writes are disallowed.
Functional change: prevents compacting single epochs when writes are
disallowed, that is when using read-only storage. Currently, the epoch
manager will attempt to perform single-epoch compactions for all
eligible epochs, even on read-only storage.

Ref:
- #3224
- #3225
- #3638
- #3639
2024-02-16 10:25:58 -08:00
Julio López
ed9d0c281e refactor(cli): miscellaneous code simplifications (#3607)
* refactor(cli): code simplification in onTerminate callback function
* refactor(test): quote strings, via %q, in assertion failure message

---------

Authored-by: Aaron Alpar <aaron.alpar@veeam.com>
2024-02-06 21:37:51 -08:00
Maxim Khitrov
f62ef51700 feat(snapshots): Implement volume shadow copy support on Windows (#3543)
* Implement volume shadow copy support on Windows

* Update go-vss version

* Fix unused variables

* Rename upload_actions*.go files

* Move vss settings to a separate policy section

* Handle existing shadow copy root

* Fix tests

* Fix lint issues

* Add cli policy test

* Add OS snapshot integration test

* Add GitHub Actions VSS test

* Fix "Incorrect function" error for root VSS snapshots

* Rename err to finalErr in createOSSnapshot

* Add OSSnapshotMode test

* Do not modify paths starting with \\?\ on Windows

* Allow warning messages in logfile tests

* Fix ignorefs not wrapping OS snapshot directory

* Retry VSS creation if another op was in progress

---------

Co-authored-by: Jarek Kowalski <jaak@jkowalski.net>
2024-02-03 21:44:41 -08:00
Jarek Kowalski
a8e4d50600 build(deps): upgraded linter to v1.55.2, fixed warnings (#3611)
* build(deps): upgraded linter to v1.55.2, fixed warnings

* removed unsafe hacks with better equivalents

* test fixes
2024-02-02 23:34:34 -08:00
Jarek Kowalski
c478141bbf refactor(repository): refactor internal/repolog package to support writing metrics in the future (#3610)
* renamed internal/repolog to internal/repodiag

* refactored initialization

* additional tests

* linter fixes
2024-02-02 22:19:24 -08:00
Nick
1d6f852cd6 fix(cli): Ensure scrubber checks all fields recursively for sensitive tags (#3589)
* Fix ScrubSensitiveData to scrub recursively
* Extend test with additional cases
2024-01-26 01:46:01 +00:00