Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - Inserted device package fields limits #3808

Merged
merged 2 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void createTabItems() {
packageInfoForm.add(dpInfoText);

dpURIField = new KapuaTextField<String>();
dpURIField.setMaxLength(125);
dpURIField.setMaxLength(2048);
dpURIField.setName("dpUri");
dpURIField.setAllowBlank(false);
dpURIField.setValidator(new TextFieldValidator(dpURIField, FieldType.URL));
Expand All @@ -125,15 +125,15 @@ public void createTabItems() {
packageInfoForm.add(dpURIField, formData);

dpNameField = new KapuaTextField<String>();
dpNameField.setMaxLength(125);
dpNameField.setMaxLength(256);
dpNameField.setName("dpName");
dpNameField.setAllowBlank(false);
dpNameField.setFieldLabel("* " + DEVICE_MSGS.packageInstallDpDialogName());
dpNameField.setToolTip(DEVICE_MSGS.devicePackageNameTooltip());
packageInfoForm.add(dpNameField, formData);

dpVersionField = new KapuaTextField<String>();
dpVersionField.setMaxLength(125);
dpVersionField.setMaxLength(256);
dpVersionField.setName("dpVersion");
dpVersionField.setValidator(new TextFieldValidator(dpVersionField, FieldType.PACKAGE_VERSION));
dpVersionField.setAllowBlank(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,16 @@ public KapuaId downloadExec(KapuaId scopeId, KapuaId deviceId, DevicePackageDown
ArgumentValidator.notNull(packageDownloadRequest.getVersion(), "packageDownloadRequest.version");
ArgumentValidator.notNull(packageDownloadOptions, "packageDownloadOptions");

//
// Check Access
AUTHORIZATION_SERVICE.checkPermission(PERMISSION_FACTORY.newPermission(DeviceManagementDomains.DEVICE_MANAGEMENT_DOMAIN, Actions.write, scopeId));

try {
packageDownloadRequest.getUri().toURL();
} catch (MalformedURLException | IllegalArgumentException ignored) {
throw new KapuaIllegalArgumentException("packageDownloadRequest.uri", packageDownloadRequest.getUri().toString());
}
verifyOverflowPackageFields(packageDownloadRequest);

//
// Check Access
AUTHORIZATION_SERVICE.checkPermission(PERMISSION_FACTORY.newPermission(DeviceManagementDomains.DEVICE_MANAGEMENT_DOMAIN, Actions.write, scopeId));

//
// Generate requestId
Expand Down Expand Up @@ -574,4 +575,12 @@ public DevicePackageUninstallOperation uninstallStatus(KapuaId scopeId, KapuaId
// Check response
return checkResponseAcceptedOrThrowError(responseMessage, () -> responseMessage.getPayload().getDevicePackageUninstallOperation());
}

private void verifyOverflowPackageFields(DevicePackageDownloadRequest packageDownloadRequest) throws KapuaIllegalArgumentException {
ArgumentValidator.lengthRange(packageDownloadRequest.getUri().toString(), null, 2048, "packageDownloadRequest.uri");
ArgumentValidator.lengthRange(packageDownloadRequest.getName(), null, 256, "packageDownloadRequest.name");
ArgumentValidator.lengthRange(packageDownloadRequest.getVersion(), null, 256, "packageDownloadRequest.version");
}


}