Skip to content

aws policy equal function #1

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

Merged
merged 6 commits into from
Jul 9, 2025
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
13 changes: 10 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-latest
- os: windows-latest
- os: macos-latest
arch: amd64
Expand All @@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install dependencies on Linux
if: matrix.os == 'ubuntu-20.04'
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y sqlite3 gcc unzip

- name: Install dependencies on Windows
Expand All @@ -53,7 +53,7 @@ jobs:
make download-sqlite

- name: Compile and test on Linux
if: matrix.os == 'ubuntu-20.04'
if: matrix.os == 'ubuntu-latest'
run: |
make compile-linux
make test-all
Expand All @@ -67,10 +67,17 @@ jobs:
Get-Content test/json_equal.sql | sqlite3.exe | Out-File -FilePath test.log
if (Select-String -Path test.log -Pattern '^[0-9_]+.[^1]$') { throw 'Test failed' }
Write-Host "json_equal tests completed successfully."

Write-Host "Running aws_policy_equal tests..."
Get-Content test/aws_policy_equal.sql | sqlite3.exe | Out-File -FilePath test.log
if (Select-String -Path test.log -Pattern '^[0-9_]+.[^1]$') { throw 'Test failed' }
Write-Host "aws_policy_equal tests completed successfully."

Write-Host "Running regexp tests..."
Get-Content test/regexp.sql | sqlite3.exe | Out-File -FilePath test.log
if (Select-String -Path test.log -Pattern '^[0-9_]+.[^1]$') { throw 'Test failed' }
Write-Host "regexp tests completed successfully."

Write-Host "Running split_part tests..."
Get-Content test/split_part.sql | sqlite3.exe | Out-File -FilePath test.log
if (Select-String -Path test.log -Pattern '^[0-9_]+.[^1]$') { throw 'Test failed' }
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,35 @@ compile-linux:
gcc -O2 -fPIC -shared -I$(SRC_DIR) $(SRC_DIR)/json_equal/*.c -o $(DIST_DIR)/json_equal.so -lsqlite3
gcc -O2 -fPIC -shared -I$(SRC_DIR) $(SRC_DIR)/regexp/*.c -o $(DIST_DIR)/regexp.so -lsqlite3
gcc -O2 -fPIC -shared -I$(SRC_DIR) $(SRC_DIR)/split_part/*.c -o $(DIST_DIR)/split_part.so -lsqlite3
gcc -O2 -fPIC -shared -I$(SRC_DIR) $(SRC_DIR)/aws_policy_equal/*.c -o $(DIST_DIR)/aws_policy_equal.so -lsqlite3

compile-windows:
gcc -O2 -shared -Isrc src/json_equal/*.c -o dist/json_equal.dll
gcc -O2 -shared -Isrc src/regexp/*.c -o dist/regexp.dll
gcc -O2 -shared -Isrc src/split_part/*.c -o dist/split_part.dll
gcc -O2 -shared -Isrc src/aws_policy_equal/*.c -o dist/aws_policy_equal.dll

compile-macos-x86:
gcc -O2 -fPIC -dynamiclib -Isrc -target x86_64-apple-macos12 src/json_equal/*.c -o dist/json_equal_x86.dylib
gcc -O2 -fPIC -dynamiclib -Isrc -target x86_64-apple-macos12 src/regexp/*.c -o dist/regexp_x86.dylib
gcc -O2 -fPIC -dynamiclib -Isrc -target x86_64-apple-macos12 src/split_part/*.c -o dist/split_part_x86.dylib
gcc -O2 -fPIC -dynamiclib -Isrc -target x86_64-apple-macos12 src/aws_policy_equal/*.c -o dist/aws_policy_equal_x86.dylib

compile-macos-arm64:
gcc -O2 -fPIC -dynamiclib -Isrc -target arm64-apple-macos12 src/json_equal/*.c -o dist/json_equal_arm64.dylib
gcc -O2 -fPIC -dynamiclib -Isrc -target arm64-apple-macos12 src/regexp/*.c -o dist/regexp_arm64.dylib
gcc -O2 -fPIC -dynamiclib -Isrc -target arm64-apple-macos12 src/split_part/*.c -o dist/split_part_arm64.dylib
gcc -O2 -fPIC -dynamiclib -Isrc -target arm64-apple-macos12 src/aws_policy_equal/*.c -o dist/aws_policy_equal_arm64.dylib

compile-macos-universal: compile-macos-x86 compile-macos-arm64
lipo -create -output dist/json_equal.dylib dist/json_equal_x86.dylib dist/json_equal_arm64.dylib
lipo -create -output dist/regexp.dylib dist/regexp_x86.dylib dist/regexp_arm64.dylib
lipo -create -output dist/split_part.dylib dist/split_part_x86.dylib dist/split_part_arm64.dylib
lipo -create -output dist/aws_policy_equal.dylib dist/aws_policy_equal_x86.dylib dist/aws_policy_equal_arm64.dylib
rm -f dist/json_equal_x86.dylib dist/json_equal_arm64.dylib
rm -f dist/regexp_x86.dylib dist/regexp_arm64.dylib
rm -f dist/split_part_x86.dylib dist/split_part_arm64.dylib
rm -f dist/aws_policy_equal_x86.dylib dist/aws_policy_equal_arm64.dylib

pack-linux:
zip -j dist/stackql-sqlite-ext-functions-linux-amd64.zip dist/*.so
Expand All @@ -62,6 +68,7 @@ test-all:
@make test suite=json_equal
@make test suite=regexp
@make test suite=split_part
@make test suite=aws_policy_equal

# fails if grep does find a failed test case
test:
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<a href="https://sqlpkg.org/?q=stackql/split_part">
<img src="https://img.shields.io/badge/sqlpkg-stackql/split_part-blue">
</a>
<a href="https://sqlpkg.org/?q=stackql/aws_policy_equal">
<img src="https://img.shields.io/badge/sqlpkg-stackql/aws_policy_equal-blue">
</a>
<a href="https://github.com/stackql/sqlite-ext-functions/actions/workflows/build.yml">
<img src="https://github.com/stackql/sqlite-ext-functions/actions/workflows/build.yml/badge.svg" alt="Build Status">
</a>
Expand Down Expand Up @@ -34,6 +37,7 @@ This repository contains a set of extended functions for SQLite designed to enha
## Features

- **JSON Functions**: Includes `json_equal` to compare JSON objects and arrays.
- **AWS Policy Functions**: Includes `aws_policy_equal` to compare AWS IAM policies semantically.
- **Regular Expression Functions**: Includes `regexp_like`, `regexp_substr`, and `regexp_replace` for pattern matching and manipulation.
- **String Splitting Function**: Includes `split_part` to split strings based on a separator and retrieve specific parts.

Expand Down Expand Up @@ -73,6 +77,7 @@ After compilation, you can load the extensions in your SQLite shell using:
.load '/path/to/dist/json_equal'
.load '/path/to/dist/regexp'
.load '/path/to/dist/split_part'
.load '/path/to/dist/aws_policy_equal'
```

Alternatively, you can download the extensions from [__sqlpkg__](https://sqlpkg.org/?q=stackql%2Fjson_equal).
Expand All @@ -85,7 +90,21 @@ Alternatively, you can download the extensions from [__sqlpkg__](https://sqlpkg.
SELECT json_equal('{"key": "value"}', '{"key": "value"}'); -- Returns 1 (true)
SELECT json_equal('[1, 2, 3]', '[3, 2, 1]'); -- Returns 0 (false)
```
### AWS Policy Functions

```sql
-- Compare AWS policies with different element ordering
SELECT aws_policy_equal(
'{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:GetObject","s3:PutObject"],"Resource":"*"}]}',
'{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:PutObject","s3:GetObject"],"Resource":"*"}]}'
); -- Returns 1 (true)

-- Compare trust policies with different Principal formats
SELECT aws_policy_equal(
'{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::123456789012:role/role1"},"Action":"sts:AssumeRole"}]}',
'{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":["arn:aws:iam::123456789012:role/role1"]},"Action":"sts:AssumeRole"}]}'
); -- Returns 1 (true)
```
### Regular Expression Functions

```sql
Expand Down Expand Up @@ -119,6 +138,10 @@ Clean the distribution directory and test logs:
make clean
```

### Publishing to `sqlpkg`

To publish new functions to [`sqlpkg`](https://sqlpkg.org/), raise a PR to [nalgeon/sqlpkg](https://github.com/nalgeon/sqlpkg) adding the new function manifest JSON files.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Expand Down
Loading
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy