Skip to content

Commit ec9f8cc

Browse files
authored
Merge pull request #251 from iExecBlockchainComputing/release/8.5.0
Release/8.5.0
2 parents d65b4f6 + d0f9f6b commit ec9f8cc

File tree

61 files changed

+2413
-951
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2413
-951
lines changed

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,42 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [[8.5.0]](https://github.com/iExecBlockchainComputing/iexec-sms/releases/tag/v8.5.0) 2024-02-29
6+
7+
### New Features
8+
9+
- Export metrics on TEE challenges and Ethereum Credentials counts. (#230)
10+
- Add a cache mechanism for secret existence. (#231)
11+
- Expose cache metrics and refactor cache implementation. (#238)
12+
- Set permissions to read-only on AES Key File. (#242)
13+
- Backup AES Key File with database backup. (#243)
14+
- Copy AES Key File on database copy. (#244)
15+
- Delete AES Key File on database delete. (#245)
16+
- Restore AES Key File on database restoration. (#246)
17+
- Create TEE session with worker IPFS storage token and fallback on requester token. (#248)
18+
19+
### Bug Fixes
20+
21+
- Validate authorization first when working on compute secrets. (#229)
22+
- Remove outdated empty log assertions in session tests. (#233)
23+
- Do not use `@Data` lombok annotations on entities. (#235)
24+
- Forbid access to sensitive APIs when no API key has been configured. (#249 #252)
25+
26+
### Quality
27+
28+
- Optimize chain calls in `AuthorizationService`. (#228)
29+
- Fix licence headers in some source files. (#232)
30+
- Move `EthereumCredentials` class to `com.iexec.sms.tee.challenge` package. (#234)
31+
- Use `@DataJpaTest` to run secrets and TEE challenges tests on H2 database. (#236 #237)
32+
- Insert secrets in a single SQL statement. (#238)
33+
- Remove unused method in `AuthorizationService`, update `AuthorizationServiceTests`. (#240)
34+
- Move `ApiKeyRequestFilter` class to `com.iexec.sms.admin` package. (#241)
35+
- Clean App compute secret endpoints on `AppComputeSecretController`. (#247)
36+
37+
### Dependency Upgrades
38+
39+
- Upgrade to `iexec-common` 8.4.0. (#250)
40+
541
## [[8.4.0]](https://github.com/iExecBlockchainComputing/iexec-sms/releases/tag/v8.4.0) 2024-01-10
642

743
### New Features

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ dependencies {
8888
implementation "io.github.openfeign:feign-jackson:$openFeignVersion"
8989
implementation "io.github.openfeign:feign-slf4j:$openFeignVersion"
9090

91+
// expiring map
92+
implementation "net.jodah:expiringmap:0.5.11"
93+
9194
// test
9295
testImplementation 'org.springframework.boot:spring-boot-starter-test'
9396
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
version=8.4.0
2-
iexecCommonVersion=8.3.1
1+
version=8.5.0
2+
iexecCommonVersion=8.4.0
33
iexecCommonsPocoVersion=3.2.0
44

55
nexusUser

iexec-sms-library/src/main/java/com/iexec/sms/api/SmsClient.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2023 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2022-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,8 +36,11 @@
3636
*/
3737
public interface SmsClient {
3838

39+
// Define Application Developer secret index
40+
static final String APP_DEVELOPER_SECRET_INDEX = "1";
41+
3942
// region Secrets
40-
@RequestLine("POST /apps/{appAddress}/secrets/1")
43+
@RequestLine("POST /apps/{appAddress}/secrets")
4144
@Headers("Authorization: {authorization}")
4245
ApiResponseBody<String, List<String>> addAppDeveloperAppComputeSecret(
4346
@Param("authorization") String authorization,
@@ -46,12 +49,21 @@ ApiResponseBody<String, List<String>> addAppDeveloperAppComputeSecret(
4649
String secretValue
4750
);
4851

52+
/**
53+
* @deprecated Call {@code isAppDeveloperAppComputeSecretPresent(appAddress)}
54+
*/
55+
@Deprecated(forRemoval = true)
4956
@RequestLine("HEAD /apps/{appAddress}/secrets/{secretIndex}")
5057
ApiResponseBody<String, List<String>> isAppDeveloperAppComputeSecretPresent(
5158
@Param("appAddress") String appAddress,
5259
@Param("secretIndex") String secretIndex
5360
);
5461

62+
@RequestLine("HEAD /apps/{appAddress}/secrets")
63+
ApiResponseBody<String, List<String>> isAppDeveloperAppComputeSecretPresent(
64+
@Param("appAddress") String appAddress
65+
);
66+
5567
@RequestLine("POST /requesters/{requesterAddress}/secrets/{secretKey}")
5668
@Headers("Authorization: {authorization}")
5769
ApiResponseBody<String, List<String>> addRequesterAppComputeSecret(

iexec-sms-library/src/main/java/com/iexec/sms/metric/SecretsMetrics.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616

1717
package com.iexec.sms.metric;
1818

19-
import lombok.*;
19+
import lombok.AllArgsConstructor;
20+
import lombok.Builder;
21+
import lombok.Getter;
22+
import lombok.NoArgsConstructor;
2023

2124
@Builder
2225
@NoArgsConstructor
@@ -27,4 +30,5 @@ public class SecretsMetrics {
2730
private long initialCount;
2831
private long storedCount;
2932
private long addedSinceStartCount;
33+
private long cachedSecretsCount;
3034
}

src/itest/java/com/iexec/sms/secret/compute/TeeTaskComputeSecretIntegrationTests.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2023 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2021-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -101,19 +101,18 @@ public void setUp() {
101101

102102
@Test
103103
void shouldAddNewComputeSecrets() {
104-
final String appDeveloperSecretIndex = "1";
105104
final String requesterSecretKey = "secret-key";
106105
final String requesterAddress = REQUESTER_ADDRESS;
107106
final String appAddress = APP_ADDRESS;
108107
final String secretValue = SECRET_VALUE;
109108
final String ownerAddress = OWNER_ADDRESS;
110109

111-
addNewAppDeveloperSecret(appAddress, appDeveloperSecretIndex, secretValue, ownerAddress);
110+
addNewAppDeveloperSecret(appAddress, SmsClient.APP_DEVELOPER_SECRET_INDEX, secretValue, ownerAddress);
112111
addNewRequesterSecret(requesterAddress, requesterSecretKey, secretValue);
113112

114113
// Check the new secrets exists for the API
115114
try {
116-
apiClient.isAppDeveloperAppComputeSecretPresent(appAddress, appDeveloperSecretIndex);
115+
apiClient.isAppDeveloperAppComputeSecretPresent(appAddress);
117116
} catch (FeignException e) {
118117
Assertions.assertThat(e.status()).isEqualTo(HttpStatus.NO_CONTENT.value());
119118
}
@@ -133,7 +132,7 @@ void shouldAddNewComputeSecrets() {
133132
.onChainObjectType(OnChainObjectType.APPLICATION)
134133
.onChainObjectAddress(appAddress)
135134
.secretOwnerRole(SecretOwnerRole.APPLICATION_DEVELOPER)
136-
.key(appDeveloperSecretIndex)
135+
.key(SmsClient.APP_DEVELOPER_SECRET_INDEX)
137136
.build(),
138137
exampleMatcher
139138
)
@@ -145,7 +144,7 @@ void shouldAddNewComputeSecrets() {
145144
return;
146145
}
147146
Assertions.assertThat(appDeveloperSecret.get().getHeader().getOnChainObjectAddress()).isEqualToIgnoringCase(appAddress);
148-
Assertions.assertThat(appDeveloperSecret.get().getHeader().getKey()).isEqualTo(appDeveloperSecretIndex);
147+
Assertions.assertThat(appDeveloperSecret.get().getHeader().getKey()).isEqualTo(SmsClient.APP_DEVELOPER_SECRET_INDEX);
149148
Assertions.assertThat(appDeveloperSecret.get().getValue()).isNotEqualTo(secretValue);
150149
Assertions.assertThat(appDeveloperSecret.get().getValue()).isEqualTo(encryptionService.encrypt(secretValue));
151150

@@ -173,7 +172,7 @@ void shouldAddNewComputeSecrets() {
173172

174173
// We shouldn't be able to add a new secrets to the database with the same IDs
175174
try {
176-
final String authorization = getAuthorizationForAppDeveloper(appAddress, appDeveloperSecretIndex, secretValue);
175+
final String authorization = getAuthorizationForAppDeveloper(appAddress, SmsClient.APP_DEVELOPER_SECRET_INDEX, secretValue);
177176
apiClient.addAppDeveloperAppComputeSecret(authorization, appAddress, secretValue);
178177
Assertions.fail("A second app developer secret with the same app address and index should be rejected.");
179178
} catch (FeignException.Conflict ignored) {
@@ -192,7 +191,7 @@ void shouldAddNewComputeSecrets() {
192191
try {
193192
when(iexecHubService.getOwner(UPPER_CASE_APP_ADDRESS)).thenReturn(ownerAddress);
194193

195-
final String authorization = getAuthorizationForAppDeveloper(UPPER_CASE_APP_ADDRESS, appDeveloperSecretIndex, secretValue);
194+
final String authorization = getAuthorizationForAppDeveloper(UPPER_CASE_APP_ADDRESS, SmsClient.APP_DEVELOPER_SECRET_INDEX, secretValue);
196195
apiClient.addAppDeveloperAppComputeSecret(authorization, UPPER_CASE_APP_ADDRESS, secretValue);
197196
Assertions.fail("A second app developer secret with the same index " +
198197
"and an app address whose only difference is the case should be rejected.");
@@ -242,7 +241,7 @@ private void addNewAppDeveloperSecret(String appAddress, String secretIndex, Str
242241

243242
// At first, no secret should be in the database
244243
try {
245-
apiClient.isAppDeveloperAppComputeSecretPresent(appAddress, secretIndex);
244+
apiClient.isAppDeveloperAppComputeSecretPresent(appAddress);
246245
Assertions.fail("No application developer secret was expected but one has been retrieved.");
247246
} catch (FeignException.NotFound ignored) {
248247
// Having a Not Found exception is what we expect there.

src/main/java/com/iexec/sms/admin/AdminController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2023-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ private enum BackupAction {
5050
/**
5151
* The name of the database backup file.
5252
*/
53-
private static final String BACKUP_FILENAME = "backup.sql";
53+
private static final String BACKUP_DATABASE_FILENAME = "backup.sql";
5454

5555
/**
5656
* We want to perform one operation at a time. This ReentrantLock is used to set up the lock mechanism.
@@ -200,7 +200,7 @@ private ResponseEntity<Void> performOperation(String sourceStorageID, String sou
200200

201201
switch (operationType) {
202202
case BACKUP:
203-
operationSuccessful = adminService.createDatabaseBackupFile(adminStorageLocation + BACKUP_STORAGE_LOCATION, BACKUP_FILENAME);
203+
operationSuccessful = adminService.createBackupFile(adminStorageLocation + BACKUP_STORAGE_LOCATION, BACKUP_DATABASE_FILENAME);
204204
break;
205205
case RESTORE:
206206
operationSuccessful = adminService.restoreDatabaseFromBackupFile(sourceStoragePath, sourceFileName);
@@ -211,7 +211,7 @@ private ResponseEntity<Void> performOperation(String sourceStorageID, String sou
211211
case REPLICATE:
212212
destinationStoragePath = getStoragePathFromID(destinationStorageID);
213213
operationSuccessful = adminService.copyBackupFile(
214-
adminStorageLocation + BACKUP_STORAGE_LOCATION, BACKUP_FILENAME, destinationStoragePath, destinationFileName);
214+
adminStorageLocation + BACKUP_STORAGE_LOCATION, BACKUP_DATABASE_FILENAME, destinationStoragePath, destinationFileName);
215215
break;
216216
case COPY:
217217
destinationStoragePath = getStoragePathFromID(destinationStorageID);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2024-2024 IEXEC BLOCKCHAIN TECH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.iexec.sms.admin;
17+
18+
/**
19+
* Enum to manage error on administration operations
20+
*/
21+
public enum AdminOperationError {
22+
23+
BACKUP_FILE_OUTSIDE_STORAGE("Backup file is outside of storage file system"),
24+
DATABASE_BACKUP_FILE_NOT_EXIST("Database backup file does not exist"),
25+
AES_KEY_BACKUP_FILE_NOT_EXIST("AES KEY backup file does not exist"),
26+
REPLICATE_OR_COPY_FILE_OUTSIDE_STORAGE("Replicated or Copied backup file destination is outside of storage file system"),
27+
DATABASE_FILE_ALREADY_EXIST("A file already exists at the destination of database file"),
28+
AES_KEY_FILE_ALREADY_EXIST("A file already exists at the destination of AES Key file"),
29+
AES_KEY_FILE_WRITE_PERMISSIONS("Can't add write permissions to AES Key file permissions");
30+
31+
private final String description;
32+
33+
AdminOperationError(String description) {
34+
this.description = description;
35+
}
36+
37+
@Override
38+
public String toString() {
39+
return description;
40+
}
41+
}

0 commit comments

Comments
 (0)