fix(lambda): attach code signing configs to functions (#6857)

* feat(lambda): attach code signing configs to functions

* fix(lambda): align code-signing IAM function names

* fix(lambda): preserve code-signing config on CreateFunction

* fix(lambda): align code-signing attachment response paths
This commit is contained in:
Jimmy Liu Jia authored and GitHub committed 2026-10-28 23:00:50 -04:00
1 parent 407ac4e210
commit 5ffe6d1123
21 files changed
+1448 -105

No files matched your search

@@ -357,6 +357,19 @@ class IamRestRouteEnforcementIntegrationTest {
}
}
@Test
void lambdaCodeSigningNamespacedFunctionIsCheckedAgainstItsTarget() {
String user = user("route-lambda-code-signing-namespace");
String name = "route-protected-" + suffix();
String function = "arn:aws:lambda:us-east-1:" + ACCOUNT + ":function:" + name;
String path = "/2020-06-30/functions/function:" + name + "/code-signing-config";
policy(user, allow("lambda:GetFunctionCodeSigningConfig", function + "-other"));
refused(send(user, "GET", path), "lambda:GetFunctionCodeSigningConfig");
policy(user, allow("lambda:GetFunctionCodeSigningConfig", function));
send(user, "GET", path).statusCode(not(403));
}
@Test
void lambdaMappingConfigAndLayerRoutesAreCheckedAgainstWhatTheyName() {
// A grant on the same resource in another account does not cover the caller's own.
@@ -1653,6 +1653,14 @@ class ResourceArnBuilderTest {
builder.build("lambda", ctx, "us-east-1", "000000000000"));
}
@Test
void lambdaCodeSigningUsesTheNamespacedFunctionTarget() {
when(uriInfo.getPath()).thenReturn(
"/2020-06-30/functions/function:protected/code-signing-config");
assertEquals("arn:aws:lambda:us-east-1:000000000000:function:protected",
builder.build("lambda", ctx, "us-east-1", ACCOUNT));
}
@Test
void lambdaInvokeKeepsTheQualifierItRuns() {
when(uriInfo.getPath()).thenReturn(
@@ -57,6 +57,20 @@ class LambdaArnUtilsTest {
assertEquals(emptyToNull(expectedAccount), ref.account());
}
@Test
void resolveNamespacedFunctionNameUsesTheAttachmentTargetAcrossPrefixes() {
LambdaArnUtils.ResolvedFunctionRef namespaced =
LambdaArnUtils.resolveNamespacedFunctionName("function:protected:$LATEST");
assertEquals("protected", namespaced.name());
assertEquals("$LATEST", namespaced.qualifier());
LambdaArnUtils.ResolvedFunctionRef partial =
LambdaArnUtils.resolveNamespacedFunctionName("us-east-1:111111111111:protected");
assertEquals("protected", partial.name());
assertEquals("us-east-1", partial.region());
assertEquals("111111111111", partial.account());
}
@ParameterizedTest
@ValueSource(strings = {
"",
@@ -0,0 +1,295 @@
package io.github.hectorvent.floci.services.lambda;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
import io.github.hectorvent.floci.services.lambda.model.LambdaFunction;
import io.github.hectorvent.floci.services.lambda.zip.CodeStore;
import io.github.hectorvent.floci.services.lambda.zip.ZipExtractor;
import jakarta.ws.rs.core.Response;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.nio.file.Path;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
/** Code-signing mutations stay in the account selected by the request context. */
class LambdaCodeSigningAccountScopeTest {
private static final String REGION = "us-east-1";
private static final String CALLER_ACCOUNT = "111111111111";
private static final String ARN_ACCOUNT = "222222222222";
private static final String FUNCTION_NAME = "same-name";
private static final String CONFIG_ARN =
"arn:aws:lambda:us-east-1:111111111111:code-signing-config:csc-0123456789abcdef0";
@Test
void foreignFullArnCannotMutateSameNamedCallerFunction(@TempDir Path codePath) {
LambdaFunctionStore store = new LambdaFunctionStore(
AccountAwareStorageBackend.inMemory(CALLER_ACCOUNT));
store.saveForAccount(CALLER_ACCOUNT, REGION, function(CALLER_ACCOUNT));
store.saveForAccount(ARN_ACCOUNT, REGION, function(ARN_ACCOUNT));
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), new RegionResolver(REGION, CALLER_ACCOUNT));
String foreignArn = "arn:aws:lambda:" + REGION + ":" + ARN_ACCOUNT
+ ":function:" + FUNCTION_NAME;
AwsException putError = assertThrows(AwsException.class,
() -> service.putFunctionCodeSigningConfig(REGION, foreignArn, CONFIG_ARN));
assertEquals("ResourceNotFoundException", putError.getErrorCode());
assertNull(store.getForAccount(CALLER_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getCodeSigningConfigArn());
assertNull(store.getForAccount(ARN_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getCodeSigningConfigArn());
AwsException deleteError = assertThrows(AwsException.class,
() -> service.deleteFunctionCodeSigningConfig(REGION, foreignArn));
assertEquals("ResourceNotFoundException", deleteError.getErrorCode());
assertNull(store.getForAccount(CALLER_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getCodeSigningConfigArn());
assertNull(store.getForAccount(ARN_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getCodeSigningConfigArn());
}
@Test
void foreignPartialArnCannotMutateSameNamedCallerFunction(@TempDir Path codePath) {
LambdaFunctionStore store = new LambdaFunctionStore(
AccountAwareStorageBackend.inMemory(CALLER_ACCOUNT));
store.saveForAccount(CALLER_ACCOUNT, REGION, function(CALLER_ACCOUNT));
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), new RegionResolver(REGION, CALLER_ACCOUNT));
String foreignArn = ARN_ACCOUNT + ":function:" + FUNCTION_NAME;
AwsException error = assertThrows(AwsException.class,
() -> service.putFunctionCodeSigningConfig(REGION, foreignArn, CONFIG_ARN));
assertEquals("ResourceNotFoundException", error.getErrorCode());
assertNull(store.getForAccount(CALLER_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getCodeSigningConfigArn());
}
@Test
void namespacedFunctionNameAcceptsAllPartialFormsForAttachmentLifecycle(@TempDir Path codePath) {
LambdaFunctionStore store = new LambdaFunctionStore(
AccountAwareStorageBackend.inMemory(CALLER_ACCOUNT));
store.saveForAccount(CALLER_ACCOUNT, REGION, function(CALLER_ACCOUNT));
RegionResolver regions = new RegionResolver(REGION, CALLER_ACCOUNT);
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), regions);
LambdaCodeSigningController controller = new LambdaCodeSigningController(
service, mock(LambdaCodeSigningConfigService.class), regions, new ObjectMapper());
List<String> references = List.of(
REGION + ":" + CALLER_ACCOUNT + ":function:" + FUNCTION_NAME,
REGION + ":" + CALLER_ACCOUNT + ":" + FUNCTION_NAME,
REGION + ":function:" + FUNCTION_NAME,
REGION + ":" + FUNCTION_NAME,
CALLER_ACCOUNT + ":function:" + FUNCTION_NAME,
CALLER_ACCOUNT + ":" + FUNCTION_NAME,
"function:" + FUNCTION_NAME,
FUNCTION_NAME,
CALLER_ACCOUNT + ":function:" + FUNCTION_NAME + ":$LATEST");
for (String reference : references) {
service.putFunctionCodeSigningConfig(REGION, reference, CONFIG_ARN);
Response response = controller.getFunctionCodeSigningConfig(null, reference);
assertEquals(200, response.getStatus(), reference);
assertEquals(CONFIG_ARN, store.getForAccount(CALLER_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getCodeSigningConfigArn(), reference);
service.deleteFunctionCodeSigningConfig(REGION, reference);
assertNull(store.getForAccount(CALLER_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getCodeSigningConfigArn(), reference);
}
}
@Test
void namespacedFunctionNameAllowsFunctionAsTheFunctionName(@TempDir Path codePath) {
LambdaFunctionStore store = new LambdaFunctionStore(
AccountAwareStorageBackend.inMemory(CALLER_ACCOUNT));
LambdaFunction function = function(CALLER_ACCOUNT);
function.setFunctionName("function");
function.setFunctionArn("arn:aws:lambda:" + REGION + ":" + CALLER_ACCOUNT
+ ":function:function");
store.saveForAccount(CALLER_ACCOUNT, REGION, function);
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), new RegionResolver(REGION, CALLER_ACCOUNT));
service.putFunctionCodeSigningConfig(REGION,
REGION + ":" + CALLER_ACCOUNT + ":function", CONFIG_ARN);
assertEquals(CONFIG_ARN, store.getForAccount(CALLER_ACCOUNT, REGION, "function")
.orElseThrow().getCodeSigningConfigArn());
}
@Test
void namespacedFunctionNameKeepsPrefixShapedBareNames(@TempDir Path codePath) {
LambdaFunctionStore store = new LambdaFunctionStore(
AccountAwareStorageBackend.inMemory(CALLER_ACCOUNT));
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), new RegionResolver(REGION, CALLER_ACCOUNT));
for (String name : List.of(REGION, CALLER_ACCOUNT, "function")) {
LambdaFunction function = function(CALLER_ACCOUNT);
function.setFunctionName(name);
function.setFunctionArn("arn:aws:lambda:" + REGION + ":" + CALLER_ACCOUNT + ":function:" + name);
store.saveForAccount(CALLER_ACCOUNT, REGION, function);
service.putFunctionCodeSigningConfig(REGION, name, CONFIG_ARN);
assertEquals(CONFIG_ARN, service.getFunctionForCodeSigningConfig(REGION, name + ":$LATEST")
.getCodeSigningConfigArn(), name);
service.deleteFunctionCodeSigningConfig(REGION, name + ":$LATEST");
assertNull(store.getForAccount(CALLER_ACCOUNT, REGION, name)
.orElseThrow().getCodeSigningConfigArn(), name);
}
}
@Test
void foreignPartitionArnCannotSelectCallerFunction(@TempDir Path codePath) {
LambdaFunctionStore store = new LambdaFunctionStore(
AccountAwareStorageBackend.inMemory(CALLER_ACCOUNT));
store.saveForAccount(CALLER_ACCOUNT, REGION, function(CALLER_ACCOUNT));
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), new RegionResolver(REGION, CALLER_ACCOUNT));
String foreignArn = "arn:aws-us-gov:lambda:" + REGION + ":" + CALLER_ACCOUNT
+ ":function:" + FUNCTION_NAME;
AwsException error = assertThrows(AwsException.class,
() -> service.putFunctionCodeSigningConfig(REGION, foreignArn, CONFIG_ARN));
assertEquals("ResourceNotFoundException", error.getErrorCode());
assertNull(store.getForAccount(CALLER_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getCodeSigningConfigArn());
}
@Test
void foreignPartialRegionAndAccountReferencesCannotMutateCallerFunction(@TempDir Path codePath) {
LambdaFunctionStore store = new LambdaFunctionStore(
AccountAwareStorageBackend.inMemory(CALLER_ACCOUNT));
store.saveForAccount(CALLER_ACCOUNT, REGION, function(CALLER_ACCOUNT));
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), new RegionResolver(REGION, CALLER_ACCOUNT));
List<String> references = List.of(
"us-west-2:" + CALLER_ACCOUNT + ":function:" + FUNCTION_NAME,
"us-west-2:" + CALLER_ACCOUNT + ":" + FUNCTION_NAME,
"us-west-2:function:" + FUNCTION_NAME,
"us-west-2:" + FUNCTION_NAME,
ARN_ACCOUNT + ":function:" + FUNCTION_NAME,
ARN_ACCOUNT + ":" + FUNCTION_NAME,
REGION + ":" + ARN_ACCOUNT + ":function:" + FUNCTION_NAME,
REGION + ":" + ARN_ACCOUNT + ":" + FUNCTION_NAME);
for (String reference : references) {
AwsException error = assertThrows(AwsException.class,
() -> service.putFunctionCodeSigningConfig(REGION, reference, CONFIG_ARN), reference);
assertEquals("ResourceNotFoundException", error.getErrorCode(), reference);
assertNull(store.getForAccount(CALLER_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getCodeSigningConfigArn(), reference);
}
}
@Test
void foreignFullArnCannotReadCodeSigningConfigThroughController(@TempDir Path codePath) {
LambdaFunctionStore store = new LambdaFunctionStore(
AccountAwareStorageBackend.inMemory(CALLER_ACCOUNT));
LambdaFunction callerFunction = function(CALLER_ACCOUNT);
callerFunction.setCodeSigningConfigArn(CONFIG_ARN);
store.saveForAccount(CALLER_ACCOUNT, REGION, callerFunction);
RegionResolver regions = new RegionResolver(REGION, CALLER_ACCOUNT);
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), regions);
ObjectMapper mapper = new ObjectMapper();
LambdaCodeSigningController controller = new LambdaCodeSigningController(
service, mock(LambdaCodeSigningConfigService.class), regions, mapper);
String foreignArn = "arn:aws:lambda:" + REGION + ":" + ARN_ACCOUNT
+ ":function:" + FUNCTION_NAME;
AwsException error = assertThrows(AwsException.class,
() -> controller.getFunctionCodeSigningConfig(null, foreignArn));
assertEquals("ResourceNotFoundException", error.getErrorCode());
}
@Test
void foreignRegionArnCannotMutateCallerFunction(@TempDir Path codePath) {
LambdaFunctionStore store = new LambdaFunctionStore(
AccountAwareStorageBackend.inMemory(CALLER_ACCOUNT));
store.saveForAccount(CALLER_ACCOUNT, REGION, function(CALLER_ACCOUNT));
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), new RegionResolver(REGION, CALLER_ACCOUNT));
String foreignArn = "arn:aws:lambda:us-west-2:" + CALLER_ACCOUNT
+ ":function:" + FUNCTION_NAME;
AwsException error = assertThrows(AwsException.class,
() -> service.putFunctionCodeSigningConfig(REGION, foreignArn, CONFIG_ARN));
assertEquals("ResourceNotFoundException", error.getErrorCode());
assertNull(store.getForAccount(CALLER_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getCodeSigningConfigArn());
}
@Test
void namespacedFunctionNameAcceptsQualifiedAndDottedReferences(@TempDir Path codePath) {
LambdaFunctionStore store = new LambdaFunctionStore(
AccountAwareStorageBackend.inMemory(CALLER_ACCOUNT));
LambdaFunction function = function(CALLER_ACCOUNT);
function.setFunctionName("same.name");
function.setFunctionArn("arn:aws:lambda:" + REGION + ":" + CALLER_ACCOUNT
+ ":function:same.name");
store.saveForAccount(CALLER_ACCOUNT, REGION, function);
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), new RegionResolver(REGION, CALLER_ACCOUNT));
service.putFunctionCodeSigningConfig(REGION, "same.name:$LATEST", CONFIG_ARN);
assertEquals(CONFIG_ARN, store.getForAccount(CALLER_ACCOUNT, REGION, "same.name")
.orElseThrow().getCodeSigningConfigArn());
}
@Test
void foreignArnCannotSelectAFunctionAbsentFromTheCallerAccount(@TempDir Path codePath) {
LambdaFunctionStore store = new LambdaFunctionStore(
AccountAwareStorageBackend.inMemory(CALLER_ACCOUNT));
store.saveForAccount(ARN_ACCOUNT, REGION, function(ARN_ACCOUNT));
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), new RegionResolver(REGION, CALLER_ACCOUNT));
String foreignArn = "arn:aws:lambda:" + REGION + ":" + ARN_ACCOUNT
+ ":function:" + FUNCTION_NAME;
AwsException error = assertThrows(AwsException.class,
() -> service.putFunctionCodeSigningConfig(REGION, foreignArn, CONFIG_ARN));
assertEquals("ResourceNotFoundException", error.getErrorCode());
assertNull(store.getForAccount(ARN_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getCodeSigningConfigArn());
}
@Test
void legacyArnOwnedFunctionIsWrittenBackToTheVerifiedAccount(@TempDir Path codePath) {
InMemoryStorage<String, LambdaFunction> raw = new InMemoryStorage<>();
AccountAwareStorageBackend<LambdaFunction> backend =
new AccountAwareStorageBackend<>(raw, null, ARN_ACCOUNT);
LambdaFunctionStore store = new LambdaFunctionStore(backend);
LambdaFunction legacy = function(ARN_ACCOUNT);
legacy.setAccountId(null);
raw.put("lambda::" + REGION + "::" + FUNCTION_NAME + "::$LATEST", legacy);
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), new RegionResolver(REGION, ARN_ACCOUNT));
service.putFunctionCodeSigningConfig(REGION, FUNCTION_NAME, CONFIG_ARN);
assertEquals(CONFIG_ARN, store.getForAccount(ARN_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getCodeSigningConfigArn());
assertEquals(ARN_ACCOUNT, store.getForAccount(ARN_ACCOUNT, REGION, FUNCTION_NAME)
.orElseThrow().getAccountId());
assertTrue(store.getForAccount("000000000000", REGION, FUNCTION_NAME).isEmpty());
}
private static LambdaFunction function(String account) {
LambdaFunction function = new LambdaFunction();
function.setAccountId(account);
function.setFunctionName(FUNCTION_NAME);
function.setVersion("$LATEST");
function.setFunctionArn("arn:aws:lambda:" + REGION + ":" + account
+ ":function:" + FUNCTION_NAME);
return function;
}
}
@@ -0,0 +1,90 @@
package io.github.hectorvent.floci.services.lambda;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
import io.github.hectorvent.floci.services.lambda.model.LambdaFunction;
import io.github.hectorvent.floci.services.lambda.zip.CodeStore;
import io.github.hectorvent.floci.services.lambda.zip.ZipExtractor;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.nio.file.Path;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import static io.github.hectorvent.floci.testing.ThreadStates.awaitBlockedOrDone;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
class LambdaCodeSigningAttachmentDeleteRaceTest {
private static final String REGION = "us-east-1";
private static final String ACCOUNT = "111111111111";
private static final String NAME = "attachment-delete-race";
private static final String ARN = "arn:aws:lambda:" + REGION + ":" + ACCOUNT + ":function:" + NAME;
private static final String CONFIG_ARN = "arn:aws:lambda:" + REGION + ":" + ACCOUNT
+ ":code-signing-config:csc-0123456789abcdef0";
@Test
void putCannotRestoreFunctionDeletedWhileMutationWaitsForLock(@TempDir Path codePath) throws Exception {
assertDeletedFunctionIsNotRestored(codePath, null,
service -> service.putFunctionCodeSigningConfig(REGION, NAME, CONFIG_ARN));
}
@Test
void detachCannotRestoreFunctionDeletedWhileMutationWaitsForLock(@TempDir Path codePath) throws Exception {
assertDeletedFunctionIsNotRestored(codePath, CONFIG_ARN,
service -> service.deleteFunctionCodeSigningConfig(REGION, NAME));
}
private void assertDeletedFunctionIsNotRestored(Path codePath, String initialConfigArn,
Consumer<LambdaService> mutation) throws Exception {
LambdaFunctionStore store = new LambdaFunctionStore(AccountAwareStorageBackend.inMemory(ACCOUNT));
LambdaFunction function = new LambdaFunction();
function.setAccountId(ACCOUNT);
function.setFunctionName(NAME);
function.setFunctionArn(ARN);
function.setVersion("$LATEST");
function.setCodeSigningConfigArn(initialConfigArn);
store.saveForAccount(ACCOUNT, REGION, function);
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), new RegionResolver(REGION, ACCOUNT));
ExecutorService workerPool = Executors.newSingleThreadExecutor();
CountDownLatch started = new CountDownLatch(1);
AtomicReference<Thread> worker = new AtomicReference<>();
try {
Future<?> future;
synchronized (service.lockForConcurrencyOp(ARN)) {
future = workerPool.submit(() -> {
worker.set(Thread.currentThread());
started.countDown();
mutation.accept(service);
});
assertTrue(started.await(5, TimeUnit.SECONDS));
awaitBlockedOrDone(worker.get());
service.deleteFunction(REGION, NAME);
assertFalse(store.getForAccount(ACCOUNT, REGION, NAME).isPresent());
}
ExecutionException failure = assertThrows(ExecutionException.class,
() -> future.get(5, TimeUnit.SECONDS));
AwsException error = assertInstanceOf(AwsException.class, failure.getCause());
assertEquals("ResourceNotFoundException", error.getErrorCode());
assertFalse(store.getForAccount(ACCOUNT, REGION, NAME).isPresent());
} finally {
workerPool.shutdownNow();
}
}
}
@@ -0,0 +1,222 @@
package io.github.hectorvent.floci.services.lambda;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.Response;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
/** Wire-level lifecycle and error coverage for function code-signing attachments. */
@QuarkusTest
class LambdaCodeSigningAttachmentIntegrationTest {
private static final String CONFIGS = "/2020-04-22/code-signing-configs";
private static final String SIGNING = "/2020-06-30";
private static final String LEGACY_FUNCTIONS = "/2015-03-31/functions";
private static final String PROFILE =
"arn:aws:signer:us-east-1:000000000000:/signing-profiles/prof/AbCdEfGhIj";
@Test
void attachReadListDetachAndDeleteConfiguration() {
String functionName = "signing-lifecycle-" + System.nanoTime();
String functionPath = LEGACY_FUNCTIONS + "/" + functionName;
String arn = createConfig();
try {
createFunction(functionName);
given().contentType("application/json")
.body("{\"CodeSigningConfigArn\":\"" + arn + "\"}")
.when().put(SIGNING + "/functions/" + functionName + "/code-signing-config")
.then().statusCode(200)
.body("CodeSigningConfigArn", is(arn))
.body("FunctionName", is(functionName));
given().when().get(SIGNING + "/functions/" + functionName + "/code-signing-config")
.then().statusCode(200)
.body("CodeSigningConfigArn", is(arn))
.body("FunctionName", is(functionName));
given().when().get(functionPath + "/code-signing-config")
.then().statusCode(404);
given().queryParam("MaxItems", 1)
.when().get(CONFIGS + "/" + arn + "/functions")
.then().statusCode(200)
.body("FunctionArns", contains(
"arn:aws:lambda:us-east-1:000000000000:function:" + functionName))
.body("NextMarker", nullValue());
given().when().delete(CONFIGS + "/" + arn).then().statusCode(409)
.body("__type", is("ResourceConflictException"));
given().when().delete(SIGNING + "/functions/" + functionName + "/code-signing-config")
.then().statusCode(204);
given().when().get(SIGNING + "/functions/" + functionName + "/code-signing-config")
.then().statusCode(200)
.body("CodeSigningConfigArn", is(""));
given().when().delete(CONFIGS + "/" + arn).then().statusCode(204);
} finally {
try {
given().when().delete(functionPath);
} finally {
given().when().delete(CONFIGS + "/" + arn);
}
}
}
@Test
void putRejectsMalformedAndUnknownConfigurations() {
String functionName = "signing-negative-" + System.nanoTime();
String functionPath = LEGACY_FUNCTIONS + "/" + functionName;
createFunction(functionName);
try {
given().contentType("application/json")
.body("{\"CodeSigningConfigArn\":\"not-an-arn\"}")
.when().put(SIGNING + "/functions/" + functionName + "/code-signing-config")
.then().statusCode(400)
.body("__type", is("InvalidParameterValueException"));
given().contentType("application/json")
.body("{\"CodeSigningConfigArn\":\""
+ "arn:aws:lambda:us-east-1:000000000000:code-signing-config:csc-abcdefghij1234567"
+ "\"}")
.when().put(SIGNING + "/functions/" + functionName + "/code-signing-config")
.then().statusCode(404)
.body("__type", is("CodeSigningConfigNotFoundException"));
} finally {
given().when().delete(functionPath).then().statusCode(204);
}
}
@Test
void createFunctionAttachesExistingConfiguration() {
String functionName = "signing-create-" + System.nanoTime();
String functionPath = LEGACY_FUNCTIONS + "/" + functionName;
String arn = createConfig();
try {
given().contentType("application/json")
.body("{\"FunctionName\":\"" + functionName + "\",\"Runtime\":\"nodejs20.x\","
+ "\"Role\":\"arn:aws:iam::000000000000:role/lambda-role\","
+ "\"Handler\":\"index.handler\",\"CodeSigningConfigArn\":\"" + arn + "\"}")
.when().post(LEGACY_FUNCTIONS)
.then().statusCode(201)
.body("CodeSigningConfigArn", nullValue());
given().when().get(SIGNING + "/functions/" + functionName + "/code-signing-config")
.then().statusCode(200)
.body("CodeSigningConfigArn", is(arn));
given().when().get(LEGACY_FUNCTIONS + "/" + functionName + "/configuration")
.then().statusCode(200)
.body("CodeSigningConfigArn", nullValue());
given().when().get(functionPath)
.then().statusCode(200)
.body("Configuration.CodeSigningConfigArn", nullValue());
given().when().get(LEGACY_FUNCTIONS)
.then().statusCode(200)
.body("Functions.FunctionName", hasItem(functionName))
.body("Functions.find { it.FunctionName == '" + functionName
+ "' }.CodeSigningConfigArn", nullValue());
} finally {
given().when().delete(functionPath).then().statusCode(204);
given().when().delete(CONFIGS + "/" + arn).then().statusCode(204);
}
}
@Test
void createFunctionRejectsUnknownCodeSigningConfiguration() {
String functionName = "signing-create-missing-" + System.nanoTime();
String unknownArn = "arn:aws:lambda:us-east-1:000000000000:code-signing-config:csc-abcdefghij1234567";
given().contentType("application/json")
.body("{\"FunctionName\":\"" + functionName + "\",\"Runtime\":\"nodejs20.x\","
+ "\"Role\":\"arn:aws:iam::000000000000:role/lambda-role\","
+ "\"Handler\":\"index.handler\",\"CodeSigningConfigArn\":\"" + unknownArn + "\"}")
.when().post(LEGACY_FUNCTIONS)
.then().statusCode(404)
.body("__type", is("CodeSigningConfigNotFoundException"));
}
@Test
void listFunctionsByCodeSigningConfigPaginatesAttachedFunctions() {
String suffix = String.valueOf(System.nanoTime());
String firstFunction = "signing-page-a-" + suffix;
String secondFunction = "signing-page-b-" + suffix;
String firstPath = LEGACY_FUNCTIONS + "/" + firstFunction;
String secondPath = LEGACY_FUNCTIONS + "/" + secondFunction;
String arn = createConfig();
try {
createFunction(firstFunction);
createFunction(secondFunction);
attach(firstFunction, arn);
attach(secondFunction, arn);
Response firstPage = given().queryParam("MaxItems", 1)
.when().get(CONFIGS + "/" + arn + "/functions")
.then().statusCode(200)
.extract().response();
String firstArn = firstPage.path("FunctionArns[0]");
String marker = firstPage.path("NextMarker");
assertNotNull(firstArn);
assertNotNull(marker);
Response secondPage = given().queryParam("MaxItems", 1).queryParam("Marker", marker)
.when().get(CONFIGS + "/" + arn + "/functions")
.then().statusCode(200)
.extract().response();
String secondArn = secondPage.path("FunctionArns[0]");
assertNotNull(secondArn);
assertNotEquals(firstArn, secondArn);
assertThat(secondPage.path("FunctionArns"), hasSize(1));
assertThat(secondPage.path("NextMarker"), nullValue());
} finally {
try {
detach(firstFunction);
} finally {
try {
detach(secondFunction);
} finally {
try {
given().when().delete(firstPath);
} finally {
try {
given().when().delete(secondPath);
} finally {
given().when().delete(CONFIGS + "/" + arn);
}
}
}
}
}
}
private static String createConfig() {
return given().contentType("application/json")
.body("{\"AllowedPublishers\":{\"SigningProfileVersionArns\":[\"" + PROFILE + "\"]}}")
.when().post(CONFIGS)
.then().statusCode(201)
.extract().path("CodeSigningConfig.CodeSigningConfigArn");
}
private static void createFunction(String functionName) {
given().contentType("application/json")
.body("{\"FunctionName\":\"" + functionName + "\",\"Runtime\":\"nodejs20.x\","
+ "\"Role\":\"arn:aws:iam::000000000000:role/lambda-role\","
+ "\"Handler\":\"index.handler\"}")
.when().post(LEGACY_FUNCTIONS)
.then().statusCode(201);
}
private static void attach(String functionName, String arn) {
given().contentType("application/json")
.body("{\"CodeSigningConfigArn\":\"" + arn + "\"}")
.when().put(SIGNING + "/functions/" + functionName + "/code-signing-config")
.then().statusCode(200);
}
private static void detach(String functionName) {
given().when().delete(SIGNING + "/functions/" + functionName + "/code-signing-config")
.then().statusCode(204);
}
}
@@ -0,0 +1,187 @@
package io.github.hectorvent.floci.services.lambda;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
import io.github.hectorvent.floci.core.storage.StorageFactory;
import io.github.hectorvent.floci.services.lambda.model.CodeSigningConfig;
import io.github.hectorvent.floci.services.lambda.model.LambdaFunction;
import io.github.hectorvent.floci.services.lambda.zip.CodeStore;
import io.github.hectorvent.floci.services.lambda.zip.ZipExtractor;
import jakarta.ws.rs.core.Response;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import static io.github.hectorvent.floci.testing.ThreadStates.awaitBlockedOrDone;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
class LambdaCodeSigningConfigDeleteRaceTest {
private static final String REGION = "us-east-1";
private static final String ACCOUNT = "111111111111";
private static final String NAME = "config-delete-race";
@Test
void deleteWaitsForValidatedPutAndRejectsAttachedConfig(@TempDir Path codePath) throws Exception {
StorageFactory factory = mock(StorageFactory.class);
when(factory.create(anyString(), anyString(), any()))
.thenAnswer(invocation -> AccountAwareStorageBackend.inMemory(ACCOUNT));
RegionResolver regions = new RegionResolver(REGION, ACCOUNT);
LambdaCodeSigningConfigService configs = spy(new LambdaCodeSigningConfigService(factory, regions));
CodeSigningConfig.AllowedPublishers publishers = new CodeSigningConfig.AllowedPublishers();
publishers.setSigningProfileVersionArns(List.of(
"arn:aws:signer:us-east-1:111111111111:/signing-profiles/prof/AbCdEfGhIj"));
String configArn = configs.create(REGION, ACCOUNT, null, publishers, null).getCodeSigningConfigArn();
LambdaFunctionStore functions = new LambdaFunctionStore(AccountAwareStorageBackend.inMemory(ACCOUNT));
LambdaFunction function = new LambdaFunction();
function.setAccountId(ACCOUNT);
function.setFunctionName(NAME);
function.setFunctionArn("arn:aws:lambda:" + REGION + ":" + ACCOUNT + ":function:" + NAME);
function.setVersion("$LATEST");
functions.saveForAccount(ACCOUNT, REGION, function);
LambdaService lambda = new LambdaService(functions, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), regions);
ObjectMapper mapper = new ObjectMapper();
LambdaCodeSigningController attachments = new LambdaCodeSigningController(lambda, configs, regions, mapper);
LambdaCodeSigningConfigFunctionsController configController =
new LambdaCodeSigningConfigFunctionsController(configs, lambda, regions, mapper);
CountDownLatch validated = new CountDownLatch(1);
CountDownLatch releasePut = new CountDownLatch(1);
AtomicReference<Thread> putThread = new AtomicReference<>();
doAnswer(invocation -> {
CodeSigningConfig result = (CodeSigningConfig) invocation.callRealMethod();
if (Thread.currentThread() == putThread.get()) {
validated.countDown();
assertTrue(releasePut.await(15, TimeUnit.SECONDS));
}
return result;
}).when(configs).get(REGION, ACCOUNT, configArn);
ExecutorService workers = Executors.newFixedThreadPool(2);
try {
ObjectNode body = mapper.createObjectNode().put("CodeSigningConfigArn", configArn);
Future<Response> put = workers.submit(() -> {
putThread.set(Thread.currentThread());
return attachments.putFunctionCodeSigningConfig(null, NAME, body);
});
assertTrue(validated.await(5, TimeUnit.SECONDS));
AtomicReference<Thread> deleteThread = new AtomicReference<>();
Future<Response> delete = workers.submit(() -> {
deleteThread.set(Thread.currentThread());
return configController.deleteCodeSigningConfig(null, configArn);
});
awaitBlockedOrDone(deleteThread, delete);
assertFalse(delete.isDone(), "config deletion must wait for the validated attachment");
releasePut.countDown();
assertEquals(200, put.get(5, TimeUnit.SECONDS).getStatus());
ExecutionException failure = assertThrows(ExecutionException.class,
() -> delete.get(5, TimeUnit.SECONDS));
AwsException conflict = assertInstanceOf(AwsException.class, failure.getCause());
assertEquals("ResourceConflictException", conflict.getErrorCode());
assertEquals(409, conflict.getHttpStatus());
assertEquals(configArn, configs.get(REGION, ACCOUNT, configArn).getCodeSigningConfigArn());
assertEquals(configArn, functions.getForAccount(ACCOUNT, REGION, NAME)
.orElseThrow().getCodeSigningConfigArn());
} finally {
releasePut.countDown();
workers.shutdownNow();
}
}
@Test
void deleteWaitsForValidatedCreateAndRejectsAttachedConfig(@TempDir Path codePath) throws Exception {
StorageFactory factory = mock(StorageFactory.class);
when(factory.create(anyString(), anyString(), any()))
.thenAnswer(invocation -> AccountAwareStorageBackend.inMemory(ACCOUNT));
RegionResolver regions = new RegionResolver(REGION, ACCOUNT);
LambdaCodeSigningConfigService configs = spy(new LambdaCodeSigningConfigService(factory, regions));
CodeSigningConfig.AllowedPublishers publishers = new CodeSigningConfig.AllowedPublishers();
publishers.setSigningProfileVersionArns(List.of(
"arn:aws:signer:us-east-1:111111111111:/signing-profiles/prof/AbCdEfGhIj"));
String configArn = configs.create(REGION, ACCOUNT, null, publishers, null).getCodeSigningConfigArn();
LambdaFunctionStore functions = new LambdaFunctionStore(AccountAwareStorageBackend.inMemory(ACCOUNT));
LambdaService lambda = new LambdaService(functions, null, new LambdaConcurrencyLimiter(),
new WarmPool(), new CodeStore(codePath), new ZipExtractor(), null, regions, null, null,
new LambdaTargetResolver(functions, null), null, null, null, null, null, factory,
null, null, null, null, new ObjectMapper(), configs);
LambdaCodeSigningConfigFunctionsController configController =
new LambdaCodeSigningConfigFunctionsController(configs, lambda, regions, new ObjectMapper());
CountDownLatch validated = new CountDownLatch(1);
CountDownLatch releaseCreate = new CountDownLatch(1);
AtomicReference<Thread> createThread = new AtomicReference<>();
doAnswer(invocation -> {
CodeSigningConfig result = (CodeSigningConfig) invocation.callRealMethod();
if (Thread.currentThread() == createThread.get()) {
validated.countDown();
assertTrue(releaseCreate.await(15, TimeUnit.SECONDS));
}
return result;
}).when(configs).requireForAttachment(REGION, ACCOUNT, configArn);
String functionName = "create-config-delete-race";
Map<String, Object> request = Map.of(
"FunctionName", functionName,
"Runtime", "nodejs20.x",
"Role", "arn:aws:iam::111111111111:role/lambda-role",
"Handler", "index.handler",
"CodeSigningConfigArn", configArn);
ExecutorService workers = Executors.newFixedThreadPool(2);
try {
Future<LambdaFunction> create = workers.submit(() -> {
createThread.set(Thread.currentThread());
return lambda.createFunction(REGION, request);
});
assertTrue(validated.await(5, TimeUnit.SECONDS));
AtomicReference<Thread> deleteThread = new AtomicReference<>();
Future<Response> delete = workers.submit(() -> {
deleteThread.set(Thread.currentThread());
return configController.deleteCodeSigningConfig(null, configArn);
});
awaitBlockedOrDone(deleteThread, delete);
assertFalse(delete.isDone(), "config deletion must wait for the validated create");
releaseCreate.countDown();
assertEquals(configArn, create.get(5, TimeUnit.SECONDS).getCodeSigningConfigArn());
ExecutionException failure = assertThrows(ExecutionException.class,
() -> delete.get(5, TimeUnit.SECONDS));
AwsException conflict = assertInstanceOf(AwsException.class, failure.getCause());
assertEquals("ResourceConflictException", conflict.getErrorCode());
assertEquals(409, conflict.getHttpStatus());
assertEquals(configArn, functions.getForAccount(ACCOUNT, REGION, functionName)
.orElseThrow().getCodeSigningConfigArn());
} finally {
releaseCreate.countDown();
workers.shutdownNow();
}
}
}
@@ -14,6 +14,7 @@ import static org.hamcrest.Matchers.*;
class LambdaCodeSigningConfigIntegrationTest {
private static final String BASE_PATH = "/2015-03-31";
private static final String CODE_SIGNING_PATH = "/2020-06-30";
private static final String FUNCTION_NAME = "code-signing-test-function";
@Test
@@ -42,7 +43,7 @@ class LambdaCodeSigningConfigIntegrationTest {
void getFunctionCodeSigningConfig() {
given()
.when()
.get(BASE_PATH + "/functions/" + FUNCTION_NAME + "/code-signing-config")
.get(CODE_SIGNING_PATH + "/functions/" + FUNCTION_NAME + "/code-signing-config")
.then()
.statusCode(200)
.body("FunctionName", equalTo(FUNCTION_NAME))
@@ -54,7 +55,7 @@ class LambdaCodeSigningConfigIntegrationTest {
void getFunctionCodeSigningConfigNotFound() {
given()
.when()
.get(BASE_PATH + "/functions/nonexistent-function/code-signing-config")
.get(CODE_SIGNING_PATH + "/functions/nonexistent-function/code-signing-config")
.then()
.statusCode(404);
}
@@ -0,0 +1,103 @@
package io.github.hectorvent.floci.services.lambda;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
import io.github.hectorvent.floci.core.storage.StorageFactory;
import io.github.hectorvent.floci.services.lambda.model.CodeSigningConfig;
import io.github.hectorvent.floci.services.lambda.zip.CodeStore;
import io.github.hectorvent.floci.services.lambda.zip.ZipExtractor;
import jakarta.ws.rs.core.Response;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.nio.file.Path;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import static io.github.hectorvent.floci.testing.ThreadStates.awaitBlockedOrDone;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
class LambdaCodeSigningConfigUpdateDeleteRaceTest {
private static final String REGION = "us-east-1";
private static final String ACCOUNT = "111111111111";
@Test
void deleteWaitsForUpdateAndCannotBeUndoneByStaleSave(@TempDir Path codePath) throws Exception {
StorageFactory factory = mock(StorageFactory.class);
when(factory.create(anyString(), anyString(), any()))
.thenAnswer(invocation -> AccountAwareStorageBackend.inMemory(ACCOUNT));
RegionResolver regions = new RegionResolver(REGION, ACCOUNT);
LambdaCodeSigningConfigService configs = spy(new LambdaCodeSigningConfigService(factory, regions));
CodeSigningConfig.AllowedPublishers publishers = new CodeSigningConfig.AllowedPublishers();
publishers.setSigningProfileVersionArns(List.of(
"arn:aws:signer:us-east-1:111111111111:/signing-profiles/prof/AbCdEfGhIj"));
String arn = configs.create(REGION, ACCOUNT, null, publishers, null).getCodeSigningConfigArn();
LambdaFunctionStore functions = new LambdaFunctionStore(AccountAwareStorageBackend.inMemory(ACCOUNT));
LambdaService lambda = new LambdaService(functions, new WarmPool(), new CodeStore(codePath),
new ZipExtractor(), regions);
ObjectMapper mapper = new ObjectMapper();
LambdaCodeSigningConfigFunctionsController controller =
new LambdaCodeSigningConfigFunctionsController(configs, lambda, regions, mapper);
CountDownLatch readForUpdate = new CountDownLatch(1);
CountDownLatch releaseUpdate = new CountDownLatch(1);
AtomicReference<Thread> updateThread = new AtomicReference<>();
AtomicInteger updateReads = new AtomicInteger();
doAnswer(invocation -> {
CodeSigningConfig result = (CodeSigningConfig) invocation.callRealMethod();
if (Thread.currentThread() == updateThread.get() && updateReads.incrementAndGet() == 2) {
readForUpdate.countDown();
assertTrue(releaseUpdate.await(15, TimeUnit.SECONDS));
}
return result;
}).when(configs).get(REGION, arn);
ExecutorService workers = Executors.newFixedThreadPool(2);
try {
ObjectNode body = mapper.createObjectNode().put("Description", "updated");
Future<Response> update = workers.submit(() -> {
updateThread.set(Thread.currentThread());
return controller.updateCodeSigningConfig(null, arn, body);
});
assertTrue(readForUpdate.await(5, TimeUnit.SECONDS));
AtomicReference<Thread> deleteThread = new AtomicReference<>();
Future<Response> delete = workers.submit(() -> {
deleteThread.set(Thread.currentThread());
return controller.deleteCodeSigningConfig(null, arn);
});
awaitBlockedOrDone(deleteThread, delete);
assertFalse(delete.isDone(), "delete must wait until the update finishes");
releaseUpdate.countDown();
assertEquals(200, update.get(5, TimeUnit.SECONDS).getStatus());
assertEquals(204, delete.get(5, TimeUnit.SECONDS).getStatus());
AwsException notFound = assertThrows(AwsException.class,
() -> configs.get(REGION, ACCOUNT, arn));
assertEquals("ResourceNotFoundException", notFound.getErrorCode());
} finally {
releaseUpdate.countDown();
workers.shutdownNow();
}
}
}
@@ -31,6 +31,18 @@ class LambdaFunctionStoreAccountScopeTest {
assertEquals("other-fn", all.get(0).getFunctionName());
}
@Test
void listForAccountStaysWithinTheRequestedPartition() {
LambdaFunctionStore store = accountAwareStore();
store.saveForAccount(DEFAULT_ACCOUNT, REGION, function("default-fn", DEFAULT_ACCOUNT));
store.saveForAccount(OTHER_ACCOUNT, REGION, function("other-fn", OTHER_ACCOUNT));
assertEquals(List.of("default-fn"), store.listForAccount(DEFAULT_ACCOUNT, REGION).stream()
.map(LambdaFunction::getFunctionName).toList());
assertEquals(List.of("other-fn"), store.listForAccount(OTHER_ACCOUNT, REGION).stream()
.map(LambdaFunction::getFunctionName).toList());
}
@Test
void listAllAccountsKeepsTheRegionAndLatestFilter() {
LambdaFunctionStore store = accountAwareStore();