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

Attempt to port to 1.73.0-nightly #19

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

disconnect3d
Copy link
Contributor

This is an attempt to port the taint to 1.73.0-nightly.

This now compiles and runs, but the tests still do not pass. I am not sure exactly why and I will probably not have much time to work further on this, so I recommend anyone to feel free to take it from here.

(entry_def, x)
} else {
let msg =
"this tool currently only supports taint analysis on programs with a main function";
rustc_session::early_error(ErrorOutputType::default(), msg);
//rustc_session::early_error(ErrorOutputType::default(), msg);
panic!(msg);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has to be fixed

};

let main_id = entry_def_id.to_def_id();
let main_id = entry_def_id; //.to_def_id();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may be wrong but is likely correct

let def_id = self.tcx.hir().local_def_id(item_id).to_def_id();
//let def_id = self.tcx.hir().local_def_id(item_id).to_def_id();
//let def_id = self.tcx.hir().body_owner_def_id(rustc_hir::BodyId { hir_id: item_id }).into(); // panics
let def_id = self.tcx.hir().get_parent_item(item_id).into();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is very likely wrong, but I am not sure.

@disconnect3d
Copy link
Contributor Author

root@6d698a907a20:/host# cargo test
   Compiling taint v0.1.0 (/host)
warning: unused import: `hir::def_id::LOCAL_CRATE`
  --> src/bins/driver.rs:13:5
   |
13 | use hir::def_id::LOCAL_CRATE;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused import: `config::ErrorOutputType`
  --> src/bins/driver.rs:17:21
   |
17 | use rustc_session::{config::ErrorOutputType, EarlyErrorHandler};
   |                     ^^^^^^^^^^^^^^^^^^^^^^^

warning: panic message is not a string literal
   --> src/bins/driver.rs:120:16
    |
120 |         panic!(msg);
    |                ^^^
    |
    = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
    = note: `#[warn(non_fmt_panics)]` on by default
help: add a "{}" format string to `Display` the message
    |
120 |         panic!("{}", msg);
    |                +++++

warning: `taint` (bin "taint") generated 3 warnings (run `cargo fix --bin "taint"` to apply 3 suggestions)
    Finished test [unoptimized + debuginfo] target(s) in 1m 51s
     Running unittests src/lib.rs (target/debug/deps/taint-b6ad5ad7f2d42794)

running 3 tests
test analysis::errors::verify_taint_attribute_is_invalid_1 ... ok
test analysis::errors::verify_taint_func_received_tainted_input_0 ... ok
test analysis::taint_domain::tests::propagate ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/compiletest.rs (target/debug/deps/compiletest-ccaaa1e469289d56)

running 1 test

running 9 tests
test [ui] passes/rvalue_const_unop.rs ... ok
test [ui] passes/annotations/source.rs ... ok
test [ui] passes/annotations/sanitizer.rs ... ok
test [ui] passes/annotations/nothing.rs ... ok
test [ui] passes/switchint_is_not_sink.rs ... ok
test [ui] passes/rvalue_const.rs ... ok
test [ui] passes/context_sensitive_handles_recursion.rs ... ok
test [ui] passes/annotations/sink.rs ... ok
test [ui] passes/const_is_not_tainted.rs ... ok

test result: ok. 9 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.53s


running 8 tests
test [compile-fail] fails/context_sensitive_handles_recursion.rs ... FAILED
test [compile-fail] fails/interprocedural.rs ... FAILED
test [compile-fail] fails/simple_propagation.rs ... FAILED
test [compile-fail] fails/conditional_propagation.rs ... FAILED
test [compile-fail] fails/annotations/impl_item.rs ... FAILED
test [compile-fail] fails/plus_propagation.rs ... FAILED
test [compile-fail] fails/interprocedural_args.rs ... FAILED
test [compile-fail] fails/annotations/not_valid.rs ... FAILED

failures:

failures:
    [compile-fail] fails/annotations/impl_item.rs
    [compile-fail] fails/annotations/not_valid.rs
    [compile-fail] fails/conditional_propagation.rs
    [compile-fail] fails/context_sensitive_handles_recursion.rs
    [compile-fail] fails/interprocedural.rs
    [compile-fail] fails/interprocedural_args.rs
    [compile-fail] fails/plus_propagation.rs
    [compile-fail] fails/simple_propagation.rs

test result: FAILED. 0 passed; 8 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.78s

test test_runner ... FAILED

failures:

---- test_runner stdout ----
## Running passes tests in tests/passes against taint for target x86_64-unknown-linux-gnu
    Compiler flags: --edition 2018 -Dwarnings -Dunused
## Running fails tests in tests/fails against taint for target x86_64-unknown-linux-gnu
    Compiler flags: --edition 2018 -Dwarnings -Dunused

error: compile-fail test compiled successfully!
status: exit status: 0
command: "/host/target/debug/taint" "tests/fails/context_sensitive_handles_recursion.rs" "-L" "/tmp/compiletesteJOT8z" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletesteJOT8z/context_sensitive_handles_recursion.stage-id" "-A" "unused" "--edition" "2018" "-Dwarnings" "-Dunused" "-L" "/tmp/compiletesteJOT8z/context_sensitive_handles_recursion.stage-id.aux"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------

------------------------------------------


error: compile-fail test compiled successfully!
status: exit status: 0
command: "/host/target/debug/taint" "tests/fails/interprocedural.rs" "-L" "/tmp/compiletesteJOT8z" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletesteJOT8z/interprocedural.stage-id" "-A" "unused" "--edition" "2018" "-Dwarnings" "-Dunused" "-L" "/tmp/compiletesteJOT8z/interprocedural.stage-id.aux"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------

------------------------------------------


error: compile-fail test compiled successfully!
status: exit status: 0
command: "/host/target/debug/taint" "tests/fails/simple_propagation.rs" "-L" "/tmp/compiletesteJOT8z" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletesteJOT8z/simple_propagation.stage-id" "-A" "unused" "--edition" "2018" "-Dwarnings" "-Dunused" "-L" "/tmp/compiletesteJOT8z/simple_propagation.stage-id.aux"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------

------------------------------------------


error: compile-fail test compiled successfully!
status: exit status: 0
command: "/host/target/debug/taint" "tests/fails/conditional_propagation.rs" "-L" "/tmp/compiletesteJOT8z" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletesteJOT8z/conditional_propagation.stage-id" "-A" "unused" "--edition" "2018" "-Dwarnings" "-Dunused" "-L" "/tmp/compiletesteJOT8z/conditional_propagation.stage-id.aux"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------

------------------------------------------


error: compile-fail test compiled successfully!
status: exit status: 0
command: "/host/target/debug/taint" "tests/fails/annotations/impl_item.rs" "-L" "/tmp/compiletesteJOT8z" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletesteJOT8z/annotations/impl_item.stage-id" "-A" "unused" "--edition" "2018" "-Dwarnings" "-Dunused" "-L" "/tmp/compiletesteJOT8z/annotations/impl_item.stage-id.aux"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------

------------------------------------------


error: compile-fail test compiled successfully!
status: exit status: 0
command: "/host/target/debug/taint" "tests/fails/plus_propagation.rs" "-L" "/tmp/compiletesteJOT8z" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletesteJOT8z/plus_propagation.stage-id" "-A" "unused" "--edition" "2018" "-Dwarnings" "-Dunused" "-L" "/tmp/compiletesteJOT8z/plus_propagation.stage-id.aux"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------

------------------------------------------


error: compile-fail test compiled successfully!
status: exit status: 0
command: "/host/target/debug/taint" "tests/fails/interprocedural_args.rs" "-L" "/tmp/compiletesteJOT8z" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletesteJOT8z/interprocedural_args.stage-id" "-A" "unused" "--edition" "2018" "-Dwarnings" "-Dunused" "-L" "/tmp/compiletesteJOT8z/interprocedural_args.stage-id.aux"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------

------------------------------------------


error: failure produced the wrong error: exit status: 101
status: exit status: 101
command: "/host/target/debug/taint" "tests/fails/annotations/not_valid.rs" "-L" "/tmp/compiletesteJOT8z" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletesteJOT8z/annotations/not_valid.stage-id" "-A" "unused" "--edition" "2018" "-Dwarnings" "-Dunused" "-L" "/tmp/compiletesteJOT8z/annotations/not_valid.stage-id.aux"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
thread 'rustc' panicked at compiler/rustc_errors/src/emitter.rs:1355:84:
called `Result::unwrap()` on an `Err` value: failed while formatting fluent string `taint_attribute_is_invalid`:
message was missing

stack backtrace:
   0: rust_begin_unwind
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/library/std/src/panicking.rs:617:5
   1: core::panicking::panic_fmt
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/library/core/src/panicking.rs:67:14
   2: core::result::unwrap_failed
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/library/core/src/result.rs:1652:5
   3: <rustc_errors::emitter::EmitterWriter>::emit_message_default::{closure#0}
   4: <rustc_errors::emitter::EmitterWriter>::emit_messages_default
   5: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
   6: <rustc_errors::json::Diagnostic>::from_errors_diagnostic
   7: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
   8: <rustc_errors::HandlerInner>::emit_diagnostic::{closure#2}
   9: rustc_interface::callbacks::track_diagnostic
  10: <rustc_errors::HandlerInner>::emit_diagnostic
  11: <rustc_errors::Handler>::emit_diagnostic
  12: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic_builder::EmissionGuarantee>::diagnostic_builder_emit_producing_guarantee
  13: rustc_errors::diagnostic_builder::DiagnosticBuilder<G>::emit
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/compiler/rustc_errors/src/diagnostic_builder.rs:490:9
  14: rustc_session::parse::ParseSess::emit_err
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/compiler/rustc_session/src/parse.rs:329:30
  15: rustc_session::session::Session::emit_err
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/compiler/rustc_session/src/session.rs:507:9
  16: taint::eval::attributes::TaintAttributeFinder::visit_hir_id
             at ./src/eval/attributes.rs:74:25
  17: <taint::eval::attributes::TaintAttributeFinder as rustc_hir::intravisit::Visitor>::visit_item
             at ./src/eval/attributes.rs:88:9
  18: rustc_middle::hir::map::Map::visit_all_item_likes_in_crate
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/compiler/rustc_middle/src/hir/map/mod.rs:580:13
  19: taint::eval::main::eval_main
             at ./src/eval/main.rs:11:5
  20: taint::mir_analysis
             at ./src/bins/driver.rs:124:5
  21: core::ops::function::FnOnce::call_once
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/library/core/src/ops/function.rs:250:5
  22: rustc_middle::ty::context::GlobalCtxt::enter::{{closure}}
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/compiler/rustc_middle/src/ty/context.rs:593:37
  23: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/compiler/rustc_middle/src/ty/context/tls.rs:82:9
  24: std::thread::local::LocalKey<T>::try_with
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/library/std/src/thread/local.rs:270:16
  25: std::thread::local::LocalKey<T>::with
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/library/std/src/thread/local.rs:246:9
  26: rustc_middle::ty::context::tls::enter_context
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/compiler/rustc_middle/src/ty/context/tls.rs:79:9
  27: rustc_middle::ty::context::GlobalCtxt::enter
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/compiler/rustc_middle/src/ty/context.rs:593:9
  28: rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>::enter
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/compiler/rustc_interface/src/queries.rs:70:9
  29: taint::enter_with_fn
             at ./src/bins/driver.rs:109:5
  30: <taint::TaintCompilerCallbacks as rustc_driver_impl::Callbacks>::after_analysis
             at ./src/bins/driver.rs:98:9
  31: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

------------------------------------------

thread 'test_runner' panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiletest_rs-0.7.0/src/lib.rs:105:22:
Some tests failed
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/library/std/src/panicking.rs:649:12
   1: compiletest_rs::run_tests
             at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiletest_rs-0.7.0/src/lib.rs:105:22
   2: compiletest::run_tests
             at ./tests/compiletest.rs:73:5
   3: compiletest::run_compile_fail
             at ./tests/compiletest.rs:65:5
   4: compiletest::test_runner
             at ./tests/compiletest.rs:18:5
   5: compiletest::test_runner::{{closure}}
             at ./tests/compiletest.rs:10:18
   6: core::ops::function::FnOnce::call_once
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/library/core/src/ops/function.rs:250:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/180dffba142c47240ca0d93096ce90b9fd97c8d7/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    test_runner

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.86s

error: test failed, to rerun pass `--test compiletest`
root@6d698a907a20:/host# rustc --version
rustc 1.73.0-nightly (180dffba1 2023-08-14)

@LiHRaM LiHRaM merged commit 9e5c83b into LiHRaM:master Aug 16, 2023
1 check failed
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.

2 participants