Skip to content

build: enable http #162

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 1 commit into from
Mar 3, 2025
Merged

build: enable http #162

merged 1 commit into from
Mar 3, 2025

Conversation

jo-elimu
Copy link
Member

@jo-elimu jo-elimu commented Mar 3, 2025

Temporarily enable http:// until SSL gets enabled for the backend: elimu-ai/webapp#1694

Summary by CodeRabbit

  • New Features
    • Introduced an enhanced network security configuration to manage secure communications.
    • Updated the networking settings with revised connectivity endpoints for improved performance.

@jo-elimu jo-elimu self-assigned this Mar 3, 2025
@jo-elimu jo-elimu requested a review from a team as a code owner March 3, 2025 07:10
Copy link

coderabbitai bot commented Mar 3, 2025

Walkthrough

This pull request enhances network configuration and URL generation. It updates the Android manifest to reference a new network security configuration file and adds that XML file, which permits cleartext traffic and uses system trust anchors. Additionally, the BaseApplication’s getBaseUrl() method has been modified by updating example URLs in its comments and switching the protocol from HTTPS to HTTP. No changes were made to the structure of public or exported entities.

Changes

File(s) Change Summary
app/.../AndroidManifest.xml
app/.../network_security_config.xml
Added network security configuration: the manifest now references @xml/network_security_config, and a new XML file defines settings that allow cleartext traffic and use system certificates as trust anchors.
app/.../BaseApplication.java Updated the getBaseUrl() method by modifying the sample URLs in the comment and changing the URL protocol from "https://" to "http://".

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant OS as Android OS
    participant FS as File System
    participant BA as BaseApplication

    App->>OS: Load AndroidManifest.xml
    OS->>OS: Read networkSecurityConfig attribute (@xml/network_security_config)
    OS->>FS: Retrieve network_security_config.xml
    FS-->>OS: Return network config (cleartextTrafficPermitted, trust anchors)
    OS-->>App: Apply network security settings

    App->>BA: Call getBaseUrl()
    BA-->>App: Return HTTP base URL (with updated example URLs)
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

@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

🧹 Nitpick comments (2)
app/src/main/java/ai/elimu/content_provider/BaseApplication.java (1)

30-31: Update example URLs in comment to match HTTP protocol.

The comment examples still use the HTTPS protocol, but the implementation has changed to use HTTP. For consistency, the comment should reflect the actual protocol being used in the code.

-     * E.g. "https://eng.elimu.ai" or "https://hin.elimu.ai"
+     * E.g. "http://eng.elimu.ai" or "http://hin.elimu.ai"
app/src/main/AndroidManifest.xml (1)

9-17: Consider adding a TODO comment about reverting the network security configuration.

Similar to the code change, this manifest modification should be considered temporary. It would be helpful to add a comment in the manifest to indicate that this configuration should be removed once SSL is implemented.

<application
+        <!-- TODO: Remove network security config once SSL is implemented (issue #1694) -->
        android:networkSecurityConfig="@xml/network_security_config"
        android:name=".BaseApplication"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e84868b and 3b7d920.

📒 Files selected for processing (3)
  • app/src/main/AndroidManifest.xml (1 hunks)
  • app/src/main/java/ai/elimu/content_provider/BaseApplication.java (1 hunks)
  • app/src/main/res/xml/network_security_config.xml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/src/main/res/xml/network_security_config.xml
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build (windows-latest, 21)
  • GitHub Check: build (windows-latest, 17)
  • GitHub Check: build (ubuntu-latest, 17)

*/
public String getBaseUrl() {
Language language = SharedPreferencesHelper.getLanguage(getApplicationContext());
String url = "https://" + language.getIsoCode();
String url = "http://" + language.getIsoCode();
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

❓ Verification inconclusive

Downgrading from HTTPS to HTTP introduces security risks.

Changing from HTTPS to HTTP removes transport layer security, exposing data to potential eavesdropping and man-in-the-middle attacks. While this is acceptable as a temporary measure (per PR description "temporarily enable the use of http:// for the backend until SSL is implemented"), it's recommended to add a TODO comment to ensure this gets reverted once SSL is implemented.

-        String url = "http://" + language.getIsoCode();
+        // TODO: Revert back to HTTPS once SSL is implemented in the backend (see issue #1694)
+        String url = "http://" + language.getIsoCode();

Action: Add a TODO for HTTPS reversion when SSL is implemented

The temporary downgrade to HTTP is acceptable per the PR description but still introduces security risks by removing transport layer protection. To mitigate this risk, please add a TODO comment indicating that this change should be reverted once SSL is implemented.

  • File: app/src/main/java/ai/elimu/content_provider/BaseApplication.java (Line 35)
  • Required Change:
    • Add a TODO comment above the URL assignment to remind reverting to HTTPS when backend SSL is in place.

Diff snippet for clarity:

-        String url = "http://" + language.getIsoCode();
+        // TODO: Revert back to HTTPS once SSL is implemented in the backend (see issue #1694)
+        String url = "http://" + language.getIsoCode();
📝 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
String url = "http://" + language.getIsoCode();
// TODO: Revert back to HTTPS once SSL is implemented in the backend (see issue #1694)
String url = "http://" + language.getIsoCode();

@@ -7,6 +7,7 @@
<permission android:name="${applicationId}.provider.READ" />

<application
android:networkSecurityConfig="@xml/network_security_config"
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the network security configuration file exists and is properly configured.

Adding a network security configuration is necessary to allow HTTP cleartext traffic, which modern Android versions block by default. However, we should ensure that:

  1. The referenced XML file (@xml/network_security_config) exists in the project
  2. The configuration is properly set up to only allow cleartext traffic for specific domains
  3. This configuration is also temporary and will be removed once SSL is implemented

🏁 Script executed:

#!/bin/bash
# Check if the network_security_config.xml file exists
if [ -f "app/src/main/res/xml/network_security_config.xml" ]; then
  echo "✅ network_security_config.xml file exists."
  # Display the content of the file
  echo "Content of network_security_config.xml:"
  cat app/src/main/res/xml/network_security_config.xml
else
  echo "❌ network_security_config.xml file does not exist!"
fi

Length of output: 553


Action Required: Update Network Security Configuration to Restrict Cleartext Traffic

  • The network_security_config.xml file was found at app/src/main/res/xml/network_security_config.xml.
  • The current configuration in the file uses a <base-config> with cleartextTrafficPermitted="true", which enables cleartext traffic globally rather than for specific domains.
  • Recommendation: Update the configuration to restrict HTTP cleartext traffic to only those domains that require it. Also, document that this setup is temporary and will be removed once SSL is implemented.

@jo-elimu jo-elimu merged commit b546422 into main Mar 3, 2025
6 checks passed
@jo-elimu jo-elimu deleted the enable-http branch March 3, 2025 07:20
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