Compare commits

..

4 commits

8 changed files with 70 additions and 8 deletions

10
.drone.yml Normal file
View file

@ -0,0 +1,10 @@
---
kind: pipeline
type: docker
name: default
steps:
- name: build
image: rust:latest
commands:
- cargo test

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
/imgs
fif_*
/old
/.mypy_cache
*.sh
!clippy.sh
cargo-timing*.html

View file

@ -10,6 +10,13 @@
</Attribute>
</value>
</entry>
<entry key="/src/mimedb.rs">
<value>
<Attribute>
<option name="separator" value="&#9;" />
</Attribute>
</value>
</entry>
<entry key="/src/parameters.rs">
<value>
<Attribute>

View file

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="FacetManager">
<facet type="Python" name="Python facet">
<configuration sdkName="Python 3.9" />
</facet>
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
@ -7,8 +12,10 @@
<excludeFolder url="file://$MODULE_DIR$/imgs" />
<excludeFolder url="file://$MODULE_DIR$/old" />
<excludeFolder url="file://$MODULE_DIR$/awful" />
<excludeFolder url="file://$MODULE_DIR$/.mypy_cache" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Python 3.9 interpreter library" level="application" />
</component>
</module>

View file

@ -5,12 +5,12 @@ version = "0.2.6"
authors = ["Lynnesbian <lynne@bune.city>"]
edition = "2018"
license = "GPL-3.0-or-later"
rust-version = "1.43.0" # cached requires 1.42.0
rust-version = "1.43.0" # cached breaks on 1.42.0, i think it needs https://github.com/rust-lang/rust/pull/67642/
repository = "https://git.bune.city/lynnesbian/fif"
readme = "README.md"
keywords = ["mime", "mimetype", "utilities", "tools"]
categories = ["command-line-utilities"]
exclude = [".idea/", "Cross.toml", "*.sh"]
exclude = [".idea/", "Cross.toml", "*.sh", "*.py", ".drone.yml"]
#resolver = "2"
#license-file = "LICENSE"

View file

@ -32,6 +32,7 @@ use crate::mimedb::MimeDb;
use crate::parameters::OutputFormat;
use crate::scanerror::ScanError;
use std::process::exit;
use env_logger::Env;
mod extensionset;
mod findings;
@ -215,7 +216,10 @@ fn init_db() {
fn main() {
let args = parameters::Parameters::parse();
let mut builder = env_logger::Builder::from_default_env();
let mut builder = env_logger::Builder::from_env(
Env::new().filter_or("RUST_LOG", "WARN")
);
builder
// .format(|buf, r| writeln!(buf, "{} - {}", r.level(), r.args()))
.format_module_path(false) // don't include module in logs, as it's not necessary

View file

@ -25,11 +25,6 @@ cfg_if! {
fn init() -> Self {
let mut info = infer::Infer::new();
// jpeg2000 support because why the stinch not
info.add("image/jpeg2000", ".jp2", |buf| {
buf.len() > 23 && buf[..23] == b"\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A\x6A\x70\x32\x20"[..]
});
info.add("application/vnd.oasis.opendocument.text", "odt", |buf| {
open_document_check(buf, "text")
});

38
test.py Executable file
View file

@ -0,0 +1,38 @@
#!/usr/bin/env python
import re
import subprocess
def main():
match = re.search(
r'rust-version ?= ?"([\d.]+)"',
open("Cargo.toml", "r").read(-1)
)
if not match:
print("Couldn't find rust-version")
exit(1)
versions = [match.group(1), "stable", "beta", "nightly"]
backends = ["xdg-mime", "infer"]
done = 0
target = len(versions) * len(backends) * 2
for version in versions:
for backend in backends:
print(f"[{version}, {backend}] Tests")
subprocess.run(f"cargo +{version} test --features={backend}-backend".split(" "))
done += 1
print(f"Success - {done} of {target} complete")
print(f"[{version}, {backend}] Scanning imgs")
subprocess.run(f"cargo +{version} run --release --features={backend}-backend -- -E images imgs".split(" "))
done += 1
print(f"Success - {done} of {target} complete")
print("Done! You might want to run cargo clean...")
if __name__ == "__main__":
main()