Skip to content
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
[workspace]
resolver = "2"
members = [
"programs/gpl_session",
"programs/gpl_session/macros",
"programs/gpl_session/macros/attribute",
]

resolver = "2"

[workspace.package]
version = "3.0.10"
authors = ["Magicblock Labs <dev@magicblock.gg>"]
edition = "2021"
license = "MIT"
homepage = "https://www.magicblock.gg/"
documentation = "https://docs.magicblock.gg/"
repository = "https://github.com/magicblock-labs/session-keys"
readme = "README.md"
Comment on lines +10 to +18
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

License mismatch between workspace and member crates.

The workspace declares license = "MIT" (line 14), but all member crates declare license = "GPL-3.0-or-later". This inconsistency will likely cause licensing metadata and publishing issues. Align the workspace license to match the member crates, or clarify if different license profiles are intentional.

🤖 Prompt for AI Agents
In Cargo.toml around lines 10 to 18, the workspace.package currently sets
license = "MIT" while member crates use "GPL-3.0-or-later"; update the
workspace.package license to the SPDX identifier used by the members (e.g.,
change to "GPL-3.0-or-later") or alter the member crates to match the workspace
if MIT is intended; ensure the SPDX string is exact, save the change, and re-run
cargo metadata/publish checks to confirm consistency.


[workspace.dependencies]
session-keys = { path = "programs/gpl_session", version = "=3.0.10" }
session-keys-macros = { path = "programs/gpl_session/macros", version = "=3.0.10" }
session-keys-macros-attribute = { path = "programs/gpl_session/macros/attribute", version = "=3.0.10" }

# Magicblock

[profile.release]
overflow-checks = true
lto = "fat"
Expand Down
4 changes: 2 additions & 2 deletions programs/gpl_session/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "session-keys"
version = "3.0.10"
version = { workspace = true }
edition = "2021"
authors = ["Gum Core Dev <dev@magicblock.gg>"]
license = "GPL-3.0-or-later"
Expand All @@ -22,4 +22,4 @@ idl-build = ["anchor-lang/idl-build"]
[dependencies]
anchor-lang = "^0"
solana-security-txt = "^1.1.1"
session-keys-macros = { version = "^0.1.2", path = "macros", optional = true }
session-keys-macros = { workspace = true, path = "macros", optional = true }
4 changes: 2 additions & 2 deletions programs/gpl_session/macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "session-keys-macros"
version = "0.1.2"
version = { workspace = true }
edition = "2021"
authors = ["Magicblock Dev <dev@magicblock.gg>"]
license = "GPL-3.0-or-later"
Expand All @@ -10,4 +10,4 @@ repository = "https://github.com/magicblock-labs/gum-program-library"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
session-keys-macros-attribute = { version = "0.1.2", path = "attribute" }
session-keys-macros-attribute = { workspace = true , path = "attribute" }
2 changes: 1 addition & 1 deletion programs/gpl_session/macros/attribute/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "session-keys-macros-attribute"
version = "0.1.2"
version = { workspace = true }
edition = "2021"
authors = ["Magicblock Dev <dev@magicblock.gg>"]
license = "GPL-3.0-or-later"
Expand Down
49 changes: 49 additions & 0 deletions version_align.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

set -e

echo "Reading Cargo.toml"

# Step 1: Read the version from Cargo.toml
version=$(grep '^version = ' Cargo.toml | head -n 1 | sed 's/version = "\(.*\)"/\1/')

if [ -z "$version" ]; then
echo "Version not found in Cargo.toml"
exit 1
fi
Comment on lines +8 to +13
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Version extraction should validate workspace.package section.

Line 8 extracts the version using a simple grep pattern that matches any line starting with version = . This could incorrectly match version keys in other sections. Add validation to ensure the version is extracted from the [workspace.package] section specifically.

-version=$(grep '^version = ' Cargo.toml | head -n 1 | sed 's/version = "\(.*\)"/\1/')
+# Extract version from [workspace.package] section
+version=$(awk '/^\[workspace.package\]/,/^\[/ {if (/^version = /) print}' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
version=$(grep '^version = ' Cargo.toml | head -n 1 | sed 's/version = "\(.*\)"/\1/')
if [ -z "$version" ]; then
echo "Version not found in Cargo.toml"
exit 1
fi
# Extract version from [workspace.package] section
version=$(awk '/^\[workspace.package\]/,/^\[/ {if (/^version = /) print}' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
if [ -z "$version" ]; then
echo "Version not found in Cargo.toml"
exit 1
fi
🤖 Prompt for AI Agents
In version_align.sh around lines 8 to 13, the current grep picks any "version =
" line and may grab versions outside the [workspace.package] section; update the
extraction to first locate the [workspace.package] section and then read the
version key only within that section (e.g., scan from the line matching
'^\[workspace\.package\]' until the next section header and extract the first
'version = "..."' inside), preserve the existing empty-check and exit on
failure, and ensure the implementation robustly ignores other sections and
comments.


echo "Aligning for version: $version"

# GNU/BSD compat
sedi=(-i'')
case "$(uname)" in
# For macOS, use two parameters
Darwin*) sedi=(-i '')
esac

echo "Updating ..."

# Update the version for all crates in the Cargo.toml workspace.dependencies section
sed "${sedi[@]}" -e '/\[workspace.dependencies\]/,/# Magicblock/s/version = ".*"/version = "='$version'"/' Cargo.toml
Comment on lines +18 to +27
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix sed variable quoting and add error handling for substitution.

Line 27 has two issues:

  1. Shellcheck SC2086: The ${sedi[@]} array expansion should be quoted when passed to sed. Additionally, the shell variable $version in the replacement string needs escaping to prevent unintended regex interpretation if the version contains special characters.

  2. No validation: The sed command doesn't verify the substitution succeeded. If the [workspace.dependencies]...# Magicblock range isn't found, sed silently succeeds without modifying anything.

Apply this diff to fix escaping and add validation:

-sed "${sedi[@]}" -e '/\[workspace.dependencies\]/,/# Magicblock/s/version = ".*"/version = "='$version'"/' Cargo.toml
+sed "${sedi[@]}" -e '/\[workspace.dependencies\]/,/# Magicblock/s/version = ".*"/version = "='"${version}"'"/' Cargo.toml || {
+    echo "Error: Failed to update workspace.dependencies in Cargo.toml"
+    exit 1
+}

Additionally, consider making the sed range pattern more robust (e.g., using a stricter pattern or validating that the file structure matches expectations before attempting substitution).

🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 27-27: Double quote to prevent globbing and word splitting.

(SC2086)

🤖 Prompt for AI Agents
In version_align.sh around lines 18 to 27, the sed invocation should quote the
${sedi[@]} expansion, escape the $version value for safe insertion into the
replacement (to avoid issues with slashes, ampersands or regex metacharacters),
and validate that the substitution actually changed Cargo.toml; fix by using a
quoted expansion ("${sedi[@]}"), pre-escape the version into a safe variable
(e.g., with printf/sed to backslash-escape / and &), run sed writing to a
temporary file and check the exit/code or verify the file contains the new
version (fail with a non-zero exit and an informative error if not), and
optionally tighten the sed range regex or validate the file structure before
attempting the substitution.


# Potential for collisions in Cargo.lock, use cargo update to update it
cargo update --workspace --manifest-path ./Cargo.toml

# Check if any changes have been made to the specified files, if running with --check
if [[ "$1" == "--check" ]]; then
files_to_check=(
"Cargo.toml"
"programs/gpl_session/Cargo.toml"
"programs/gpl_session/macros/Cargo.toml"
"programs/gpl_session/macros/attribute/Cargo.toml"
)

for file in "${files_to_check[@]}"; do
# Check if the file has changed from the previous commit
if git diff --name-only | grep -q "$file"; then
echo "Error: version not aligned for $file. Align the version, commit and try again."
exit 1
fi
done
exit 0
fi