Skip to content

Feat/base64 base64url #924

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 5 commits into from
Mar 28, 2025
Merged

Feat/base64 base64url #924

merged 5 commits into from
Mar 28, 2025

Conversation

ccamel
Copy link
Member

@ccamel ccamel commented Mar 28, 2025

Following #921, this PR introduces the convenient base64/2 and base64url/2 predicates to the logic module.
These are simplified forms of base64_encoded/3, preconfigured with common options for standard and URL-safe encoding.

Summary by CodeRabbit

  • New Features

    • Expanded encoding capabilities with new options for converting plain text into both standard Base64 and URL-safe Base64 formats.
    • Added a dedicated interface for Base64 URL encoding, ensuring seamless conversion and compatibility with URL and filename requirements.
  • Tests

    • Introduced automated scenarios to validate the accurate encoding and decoding of strings using the new Base64 and URL-safe conversion features.

@ccamel ccamel self-assigned this Mar 28, 2025
Copy link
Contributor

coderabbitai bot commented Mar 28, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request expands the encoding capabilities by introducing two new predicates, Base64URL and Base64, within the encoding module. The changes include adding a new registry entry for the "base64url/2" predicate, implementing the corresponding predicate functions in the encoding file, and updating related documentation. Additionally, feature tests for both "base64/2" and "base64url/2" predicates have been added to verify correct encoding and decoding behaviors.

Changes

File(s) Change Summary
x/logic/interpreter/registry.go Added a new registry entry: {Key: "base64url/2", Value: predicate.Base64URL}.
x/logic/predicate/encoding.go Introduced two new predicates: Base64URL and Base64 with detailed signatures and descriptions; updated documentation for the existing Base64Encoded predicate.
x/logic/predicate/features/.../base64_2.feature and
x/logic/predicate/features/.../base64url_2.feature
Added two new feature files to test the behavior of the base64/2 and base64url/2 predicates, including scenarios for encoding and decoding.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant I as Interpreter
  participant R as Registry
  participant P as Predicate Function

  U->>I: Submit query with "base64url/2" predicate
  I->>R: Lookup "base64url/2" entry
  R-->>I: Return Base64URL function reference
  I->>P: Execute Base64URL with provided input
  P-->>I: Return encoded/decoded result
  I->>U: Return final query result
Loading

Possibly related PRs

Suggested reviewers

  • bdeneux
  • amimart

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7bb9b5d and e29cd56.

⛔ Files ignored due to path filters (28)
  • docs/predicate/base64_2.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/base64_encoded_3.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/base64_url_2.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/bech32_address_2.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/block_header_1.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/block_height_1.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/block_time_1.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/chain_id_1.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/consult_1.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/crypto_data_hash_3.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/current_output_1.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/did_components_2.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/ecdsa_verify_4.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/eddsa_verify_4.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/hex_bytes_2.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/json_prolog_2.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/json_read_2.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/json_write_2.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/open_3.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/open_4.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/read_string_3.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/read_term_3.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/retract_1.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/source_file_1.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/string_bytes_3.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/term_to_atom_2.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/uri_encoded_3.md is excluded by !docs/predicate/**/*.md
  • docs/predicate/write_term_3.md is excluded by !docs/predicate/**/*.md
📒 Files selected for processing (4)
  • x/logic/interpreter/registry.go (1 hunks)
  • x/logic/predicate/encoding.go (3 hunks)
  • x/logic/predicate/features/base64_2.feature (1 hunks)
  • x/logic/predicate/features/base64url_2.feature (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.go`: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

  • x/logic/interpreter/registry.go
  • x/logic/predicate/encoding.go
🧬 Code Definitions (2)
x/logic/interpreter/registry.go (1)
x/logic/predicate/encoding.go (1)
  • Base64URL (163-170)
x/logic/predicate/encoding.go (1)
x/logic/prolog/atom.go (7)
  • AtomAs (7-7)
  • AtomEncoding (19-19)
  • AtomUtf8 (57-57)
  • AtomCharset (37-37)
  • AtomPadding (35-35)
  • AtomFalse (23-23)
  • AtomTrue (55-55)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: test-go
  • GitHub Check: lint-generated
  • GitHub Check: analyze-go
  • GitHub Check: lint-go
  • GitHub Check: build-docker
🔇 Additional comments (3)
x/logic/predicate/features/base64url_2.feature (1)

1-28: LGTM: Appropriate test for base64url/2

The test case correctly demonstrates URL-safe Base64 encoding and decoding with the non-padded output format. The chosen test string <<???>> appropriately shows URL-safe character replacements.

x/logic/predicate/encoding.go (2)

149-170: LGTM: Well-implemented Base64URL function

The implementation correctly configures the Base64Encoded function with URL-safe encoding parameters (charset=url, padding=false) for use in URLs and filenames.


172-193: LGTM: Well-implemented Base64 function

The implementation correctly configures the Base64Encoded function with standard encoding parameters (charset=classic, padding=true) for regular Base64 encoding/decoding.

Copy link

codecov bot commented Mar 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #924      +/-   ##
==========================================
+ Coverage   38.58%   38.72%   +0.13%     
==========================================
  Files         113      113              
  Lines        6476     6490      +14     
==========================================
+ Hits         2499     2513      +14     
  Misses       3857     3857              
  Partials      120      120              
Files with missing lines Coverage Δ
x/logic/interpreter/registry.go 0.00% <ø> (ø)
x/logic/predicate/encoding.go 92.68% <100.00%> (+0.93%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ccamel ccamel force-pushed the feat/base64_base64url branch from e29cd56 to 8bdc625 Compare March 28, 2025 17:08
@ccamel
Copy link
Member Author

ccamel commented Mar 28, 2025

@coderabbitai resolve

Copy link
Contributor

coderabbitai bot commented Mar 28, 2025

✅ Actions performed

Comments resolved and changes approved.

@ccamel ccamel merged commit c607e44 into main Mar 28, 2025
22 checks passed
@ccamel ccamel deleted the feat/base64_base64url branch March 28, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant