Skip to content

Commit

Permalink
PM-16085 - Increase import limitations (#5275)
Browse files Browse the repository at this point in the history
* PM-16261 move ImportCiphersAsync to the tools team and create services using CQRS design pattern

* PM-16261 fix renaming methods and add unit tests for succes and bad request exception

* PM-16261 clean up old code from test

* make import limits configurable via appsettings

* PM-16085 fix issue with appSettings converting to globalSettings for new cipher import limits
  • Loading branch information
prograhamming authored Feb 5, 2025
1 parent 46004b9 commit daf2696
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Api/Tools/Controllers/ImportCiphersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ public async Task PostImport([FromQuery] string organizationId,
[FromBody] ImportOrganizationCiphersRequestModel model)
{
if (!_globalSettings.SelfHosted &&
(model.Ciphers.Count() > 7000 || model.CollectionRelationships.Count() > 14000 ||
model.Collections.Count() > 2000))
(model.Ciphers.Count() > _globalSettings.ImportCiphersLimitation.CiphersLimit ||
model.CollectionRelationships.Count() > _globalSettings.ImportCiphersLimitation.CollectionRelationshipsLimit ||
model.Collections.Count() > _globalSettings.ImportCiphersLimitation.CollectionsLimit))
{
throw new BadRequestException("You cannot import this much data at once.");
}
Expand Down
5 changes: 5 additions & 0 deletions src/Api/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
"publicKey": "SECRET",
"privateKey": "SECRET"
},
"importCiphersLimitation": {
"ciphersLimit": 40000,
"collectionRelationshipsLimit": 80000,
"collectionsLimit": 2000
},
"bitPay": {
"production": false,
"token": "SECRET",
Expand Down
8 changes: 8 additions & 0 deletions src/Core/Settings/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public virtual string LicenseDirectory
public virtual YubicoSettings Yubico { get; set; } = new YubicoSettings();
public virtual DuoSettings Duo { get; set; } = new DuoSettings();
public virtual BraintreeSettings Braintree { get; set; } = new BraintreeSettings();
public virtual ImportCiphersLimitationSettings ImportCiphersLimitation { get; set; } = new ImportCiphersLimitationSettings();
public virtual BitPaySettings BitPay { get; set; } = new BitPaySettings();
public virtual AmazonSettings Amazon { get; set; } = new AmazonSettings();
public virtual ServiceBusSettings ServiceBus { get; set; } = new ServiceBusSettings();
Expand Down Expand Up @@ -521,6 +522,13 @@ public class BraintreeSettings
public string PrivateKey { get; set; }
}

public class ImportCiphersLimitationSettings
{
public int CiphersLimit { get; set; }
public int CollectionRelationshipsLimit { get; set; }
public int CollectionsLimit { get; set; }
}

public class BitPaySettings
{
public bool Production { get; set; }
Expand Down

0 comments on commit daf2696

Please sign in to comment.