Skip to content
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

[GSK-1623] Secure Giskard readonly demo space at Hugging Face Spaces #1355

Merged
merged 68 commits into from
Sep 20, 2023

Conversation

Inokinoki
Copy link
Member

@Inokinoki Inokinoki commented Aug 30, 2023

Description

Preventing any requests with modifications (POST, PUT, DELETE) when giskardai/giskard detected.

Preventing Create, Update, Delete operations in DB after initialization.

Related Issue

Type of Change

  • 📚 Examples / docs / tutorials / dependencies update
  • 🔧 Bug fix (non-breaking change which fixes an issue)
  • 🥂 Improvement (non-breaking change which improves an existing feature)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🔐 Security fix

Checklist

  • I've read the CODE_OF_CONDUCT.md document.
  • I've read the CONTRIBUTING.md guide.
  • I've updated the code style using make codestyle.
  • I've written tests for all new methods and classes that I created.
  • I've written the docstring in Google format for all the methods and classes that I used.

@linear
Copy link

linear bot commented Aug 30, 2023

GSK-1623 Secure the demo space

Avoid uploading new projects

@andreybavt
Copy link
Contributor

since we're sending some POST requests like predict or explain we can't actually block on HTTP method level.

Instead I suggest we do it on a DB level (more precisely at JPA).

for example, if you define a class like

import jakarta.persistence.PrePersist;
import jakarta.persistence.PreRemove;
import jakarta.persistence.PreUpdate;


public class ReadOnlyListener {
    private boolean isReadOnlyGiskardInstance() {
        // TODO: implement this, probably in another class
        return true;
    }

    @PrePersist
    @PreUpdate
    @PreRemove
    void onCUD(Object o) {
        if (isReadOnlyGiskardInstance()) {
            throw new IllegalStateException("This is a read-only Giskard instance. You cannot modify entities.");
        }
    }
}

Then you'll be able to use it at an @Entity level:

@Entity(name = "api_keys")
@Getter
@NoArgsConstructor
@EntityListeners(ReadOnlyListener.class)
public class ApiKey extends AbstractAuditingEntity

In this case we could even allow some modifications but not others, like writing TestSuiteExecution (I think we could also have a scheduled method to delete old executions on demo instance so that the DB doesn't get polluted to much)

@sonarcloud
Copy link

sonarcloud bot commented Sep 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

33.3% 33.3% Coverage
0.0% 0.0% Duplication

@Inokinoki Inokinoki self-assigned this Sep 15, 2023
@sonarcloud
Copy link

sonarcloud bot commented Sep 19, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

0.0% 0.0% Coverage
0.0% 0.0% Duplication

1 similar comment
@sonarcloud
Copy link

sonarcloud bot commented Sep 19, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@kevinmessiaen kevinmessiaen merged commit d5eaa73 into main Sep 20, 2023
10 checks passed
@kevinmessiaen kevinmessiaen deleted the GSK-1623-secure-readonly-demo-space branch September 20, 2023 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants