Compare commits
4 commits
d76ed2585d
...
bcd77d9ed6
Author | SHA1 | Date | |
---|---|---|---|
bcd77d9ed6 | |||
809df5bc0e | |||
601481130f | |||
b89e71a6ab |
8 changed files with 70 additions and 8 deletions
10
.drone.yml
Normal file
10
.drone.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: rust:latest
|
||||||
|
commands:
|
||||||
|
- cargo test
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,7 @@
|
||||||
/imgs
|
/imgs
|
||||||
fif_*
|
fif_*
|
||||||
/old
|
/old
|
||||||
|
/.mypy_cache
|
||||||
*.sh
|
*.sh
|
||||||
!clippy.sh
|
!clippy.sh
|
||||||
cargo-timing*.html
|
cargo-timing*.html
|
||||||
|
|
|
@ -10,6 +10,13 @@
|
||||||
</Attribute>
|
</Attribute>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry key="/src/mimedb.rs">
|
||||||
|
<value>
|
||||||
|
<Attribute>
|
||||||
|
<option name="separator" value="	" />
|
||||||
|
</Attribute>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
<entry key="/src/parameters.rs">
|
<entry key="/src/parameters.rs">
|
||||||
<value>
|
<value>
|
||||||
<Attribute>
|
<Attribute>
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="CPP_MODULE" version="4">
|
<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">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
@ -7,8 +12,10 @@
|
||||||
<excludeFolder url="file://$MODULE_DIR$/imgs" />
|
<excludeFolder url="file://$MODULE_DIR$/imgs" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/old" />
|
<excludeFolder url="file://$MODULE_DIR$/old" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/awful" />
|
<excludeFolder url="file://$MODULE_DIR$/awful" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.mypy_cache" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="Python 3.9 interpreter library" level="application" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -5,12 +5,12 @@ version = "0.2.6"
|
||||||
authors = ["Lynnesbian <lynne@bune.city>"]
|
authors = ["Lynnesbian <lynne@bune.city>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "GPL-3.0-or-later"
|
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"
|
repository = "https://git.bune.city/lynnesbian/fif"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
keywords = ["mime", "mimetype", "utilities", "tools"]
|
keywords = ["mime", "mimetype", "utilities", "tools"]
|
||||||
categories = ["command-line-utilities"]
|
categories = ["command-line-utilities"]
|
||||||
exclude = [".idea/", "Cross.toml", "*.sh"]
|
exclude = [".idea/", "Cross.toml", "*.sh", "*.py", ".drone.yml"]
|
||||||
#resolver = "2"
|
#resolver = "2"
|
||||||
#license-file = "LICENSE"
|
#license-file = "LICENSE"
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ use crate::mimedb::MimeDb;
|
||||||
use crate::parameters::OutputFormat;
|
use crate::parameters::OutputFormat;
|
||||||
use crate::scanerror::ScanError;
|
use crate::scanerror::ScanError;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
use env_logger::Env;
|
||||||
|
|
||||||
mod extensionset;
|
mod extensionset;
|
||||||
mod findings;
|
mod findings;
|
||||||
|
@ -215,7 +216,10 @@ fn init_db() {
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = parameters::Parameters::parse();
|
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
|
builder
|
||||||
// .format(|buf, r| writeln!(buf, "{} - {}", r.level(), r.args()))
|
// .format(|buf, r| writeln!(buf, "{} - {}", r.level(), r.args()))
|
||||||
.format_module_path(false) // don't include module in logs, as it's not necessary
|
.format_module_path(false) // don't include module in logs, as it's not necessary
|
||||||
|
|
|
@ -25,11 +25,6 @@ cfg_if! {
|
||||||
fn init() -> Self {
|
fn init() -> Self {
|
||||||
let mut info = infer::Infer::new();
|
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| {
|
info.add("application/vnd.oasis.opendocument.text", "odt", |buf| {
|
||||||
open_document_check(buf, "text")
|
open_document_check(buf, "text")
|
||||||
});
|
});
|
||||||
|
|
38
test.py
Executable file
38
test.py
Executable 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()
|
||||||
|
|
Loading…
Reference in a new issue