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

use magicmime #6869

Merged
merged 6 commits into from
Aug 3, 2023
Merged

use magicmime #6869

merged 6 commits into from
Aug 3, 2023

Conversation

micbar
Copy link
Contributor

@micbar micbar commented Jul 21, 2023

Description

Getting a list of file extensions based on a mimetype is already possible in our rego files, the main downside till today was that the known range of mappings are limited.

This pr introduces the ability to provide a custom mime.types file to ocis and extend that store.
The format is based on https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types.
RFC 4288 provides more information.

Motivation and Context

The default mime.types file extension mapping is limited, we have to give the option to extend the list of known mappings.

How Has This Been Tested?

  • unit tests
  • local installation and manual testing

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@update-docs
Copy link

update-docs bot commented Jul 21, 2023

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@micbar
Copy link
Contributor Author

micbar commented Jul 21, 2023

@aduffeck you had the idea to use the file command directly via syscall.

I found no way to use the file command with a blob. The postprocessing service has no access to the path of the file on disk. We can only download the blob.

@fschade
Copy link
Contributor

fschade commented Aug 1, 2023

@micbar i hijacked the pr 😗

@fschade fschade marked this pull request as ready for review August 2, 2023 14:59
@fschade
Copy link
Contributor

fschade commented Aug 2, 2023

@mmattel FYI, i've already added some information into the readme, fine?

Copy link
Collaborator

@kobergj kobergj left a comment

Choose a reason for hiding this comment

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

Some suggestions, rest looks good 👍

@mmattel could I request your magic on the docu parts? 🙏

services/policies/pkg/engine/opa/rf_mimetype.go Outdated Show resolved Hide resolved
services/policies/pkg/engine/opa/engine.go Outdated Show resolved Hide resolved
services/policies/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@mmattel mmattel left a comment

Choose a reason for hiding this comment

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

LGTM from a docs pov 👍

services/policies/README.md Outdated Show resolved Hide resolved
scanner := bufio.NewScanner(f)
for scanner.Scan() {
fields := strings.Fields(scanner.Text())
if len(fields) <= 1 || fields[0][0] == '#' {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure that len(fields[0]) >= 1? Otherwise this will panic.

Copy link
Collaborator

Choose a reason for hiding this comment

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

After discussion we decided that we indeed are sure

@sonarcloud
Copy link

sonarcloud bot commented Aug 3, 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

38.7% 38.7% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.17) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

@kobergj kobergj merged commit 57923e0 into master Aug 3, 2023
3 checks passed
@delete-merged-branch delete-merged-branch bot deleted the magic-mime branch August 3, 2023 15:02
ownclouders pushed a commit that referenced this pull request Aug 3, 2023
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.

None yet

4 participants