mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-30 08:50:48 +01:00
s3vectors: put, get and delete vector bucket policies (#12201)
* util: do not bind outbound dials to a loopback -ip.bind `weed server -ip.bind=127.0.0.1` keeps every listener local, but the same address became the source of outbound connections, so the filer dialled its remote mount from 127.0.0.1 and failed with "connect: invalid argument". A loopback source cannot reach off the host; leave the source to the OS, as for a wildcard bind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3vectors: put, get and delete vector bucket policies The AWS S3 Vectors policy operations had no handlers; the policy document is stored on the shared table bucket, so the handlers delegate to the catalog's PutTableBucketPolicy, GetTableBucketPolicy and DeleteTableBucketPolicy and keep its guard. * s3vectors: treat ICEBERG buckets as absent in policy handlers GetVectorBucketPolicy/PutVectorBucketPolicy/DeleteVectorBucketPolicy delegated straight to the table bucket, so a bucket created for ICEBERG tables — invisible to every other vectors operation — could still have its policy read and written through the vectors API. Gate all three on lanceBucket, the same format check DeleteVectorBucket and CreateIndex already apply. * test/vectors: cover vector bucket policy put/get/delete Round-trips a policy document through the new ops and asserts a get on the deleted policy surfaces NotFoundException, so the boto3 conformance run exercises the added handlers end to end. * s3vectors: validate the bucket ARN and policy document Bucket-level operations now reject an index ARN and an ARN minted for another service, and PutVectorBucketPolicy refuses a document carrying s3vectors actions — the evaluator only honors s3tables actions, so such a rule would be a dead grant. * s3vectors: validate the bucket ARN on the remaining bucket-level operations * s3vectors: cover bucket ARN and policy document validation TestBucketARNs pins the accepted forms and the index/foreign-service rejections; TestValidatePolicyDocument covers a valid document, a malformed one, and the dead s3vectors action namespace. * s3vectors test: use an enforceable action in the bucket policy test The catalog refuses s3vectors actions in a stored policy, so the put call rejected the document before the get and delete assertions ran. --------- Co-authored-by: Ólafur Bjarki Bogason <olafur@genkiinstruments.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
7 files changed
+261
-22
No files matched your search
@@ -4,8 +4,11 @@ Run via `make test` — a mini cluster, an s3 gateway serving the vectors API on
|
||||
weed-vector are up by then.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
import boto3
|
||||
import pytest
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
ENDPOINT = "http://127.0.0.1:8334"
|
||||
BUCKET = "vectors-bucket"
|
||||
@@ -79,3 +82,31 @@ def test_vector_lifecycle(vectors):
|
||||
|
||||
vectors.delete_index(vectorBucketName=BUCKET, indexName=INDEX)
|
||||
vectors.delete_vector_bucket(vectorBucketName=BUCKET)
|
||||
|
||||
|
||||
def test_vector_bucket_policy(vectors):
|
||||
vectors.create_vector_bucket(vectorBucketName=BUCKET)
|
||||
try:
|
||||
policy = json.dumps(
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {"AWS": "*"},
|
||||
"Action": "s3tables:*",
|
||||
"Resource": "*",
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
vectors.put_vector_bucket_policy(vectorBucketName=BUCKET, policy=policy)
|
||||
got = vectors.get_vector_bucket_policy(vectorBucketName=BUCKET)["policy"]
|
||||
assert json.loads(got) == json.loads(policy)
|
||||
|
||||
vectors.delete_vector_bucket_policy(vectorBucketName=BUCKET)
|
||||
with pytest.raises(ClientError) as exc:
|
||||
vectors.get_vector_bucket_policy(vectorBucketName=BUCKET)
|
||||
assert exc.value.response["Error"]["Code"] == "NotFoundException"
|
||||
finally:
|
||||
vectors.delete_vector_bucket(vectorBucketName=BUCKET)
|
||||
Reference in new issue
Block a user