Skip to content

Added additional bad inputs and enhanced error handling.#205

Merged
milkshakeuk merged 6 commits intonHapiNET:masterfrom
AMCN41R:issue203
May 28, 2021
Merged

Added additional bad inputs and enhanced error handling.#205
milkshakeuk merged 6 commits intonHapiNET:masterfrom
AMCN41R:issue203

Conversation

@AMCN41R
Copy link
Copy Markdown
Collaborator

@AMCN41R AMCN41R commented Apr 23, 2021

Addresses issue #203

  • Added new bad input files from JlKmn/nHapiMinCrashes
  • Restructured bad input directory to support new test implementation
  • Re-implemented LegacyPipeParserBadInputTests and created PipeParserBadInputTests
  • Enhanced error handling

@milkshakeuk
Copy link
Copy Markdown
Member

@JlKmn I don't suppose you could cast your eyes over this to make sure we haven't misunderstood anything?

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@kulgg
Copy link
Copy Markdown
Contributor

kulgg commented Apr 23, 2021

@milkshakeuk no problem I will take a look soon

@kulgg
Copy link
Copy Markdown
Contributor

kulgg commented Apr 23, 2021

also i will do another last fuzzing run with a new server cluster I have access to now after the pr is done

Copy link
Copy Markdown
Contributor

@kulgg kulgg left a comment

Choose a reason for hiding this comment

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

@milkshakeuk seems good. the annoying test fails are fixed as well now. good style improvement for the parser tests.

one thing i notice when i actually pipe input into my parser harness cs program with the new nhapi package is that it gives an error for the ConfigurationManager version 4.7.0. I always fix this by changing the version in nHapi.v2.nuspec to
<dependency id="System.Configuration.ConfigurationManager" version="5.0.0" />

Might be worth an extra commit.

So far in the new Fuzzing run i have only found 1 exception after doing a short 4million executions run. The common errors are fixed. I will do a longer run now.

@github-actions

This comment has been minimized.

@milkshakeuk
Copy link
Copy Markdown
Member

@AMCN41R @JlKmn the Linux build and test action is still failing on this PR, one of the (bad) inputs, most likely a line endings git checkout issue?
Before this gets merged it would be good if we can fix this, it might require a tweak to the .gitattributes and maybe easier to debug on Linux or on windows 10 with WSL.

@kulgg
Copy link
Copy Markdown
Contributor

kulgg commented Apr 27, 2021

@milkshakeuk
From here

On unix/linux, every line in a file has an End-Of-Line (EOL) character and the EOF character is after the last line. On windows, each line has an EOL characters except the last line. So unix/linux file's last line is
stuff, EOL, EOF
whereas windows file's last line, if the cursor is on the line, is
stuff, EOF

So even though there is no newline character in the file, in Linux there is an extra 0x0A Byte at the end. That's what makes the difference i think. A .gitattributes for the BadInputs Folder could work.

@kulgg
Copy link
Copy Markdown
Contributor

kulgg commented Apr 27, 2021

Now that I think about it the correct exception for the bug is NullReference since the Fuzzing results are from Linux. The problem is with debugging these on Windows with the extra linux newline at the end missing. It just wasn't a difference maker in any of the other testcases. We just need to add an extra newline at the end when debugging under Windows. The .gitattributes can stay the same.

@kulgg
Copy link
Copy Markdown
Contributor

kulgg commented Apr 27, 2021

So i think the fix is simply adding \n after the ReadAllText in the BadInputTests
var text = File.ReadAllText(path) + "\n";
And then set the exception type to NullReference or fix the exception and set it to HL7

@github-actions

This comment has been minimized.

@kulgg
Copy link
Copy Markdown
Contributor

kulgg commented Apr 28, 2021

@AMCN41R I was wrong, i think we need a .gitattributes. The Linux Tests now have \n\n at the end, they need to always have Windows file ending without \n.

@kulgg
Copy link
Copy Markdown
Contributor

kulgg commented Apr 28, 2021

Also for the handed gracefully function adding the \n is missing

@milkshakeuk
Copy link
Copy Markdown
Member

@AMCN41R I was wrong, I think we need a .gitattributes. The Linux Tests now have \n\n at the end, they need to always have Windows file ending without \n.

@AMCN41R @JlKmn I don't think manually adding \n to the end of the input via code in the test is the right thing to do.

It might be easier to commit the files from source unmodified (using git on Linux) but instruct git via .gitattributes to treat them as binary rather than text, this will prevent the test input files line endings from being normalized regardless of their content.

This should ensure we get the same result regardless of running the tests on windows or Linux... then we can fix the parser 😁.

maybe add and commit something like this to .gitattributes before adding and committing the test data files.

tests/NHapi.NUnit/TestData/BadInputs/**/*   -text

This should instruct git to prevent attempting to normalize the files regardless of content.

@kulgg
Copy link
Copy Markdown
Contributor

kulgg commented May 4, 2021

@milkshakeuk ok I will add the additional Fuzz Results from my last run as an issue. not that many crash inputs.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown

Unit Test Results

       5 files     103 suites   16s ⏱️
   926 tests    920 ✔️   6 💤 0 ❌
1 797 runs  1 786 ✔️ 11 💤 0 ❌

Results for commit 12aafec.

@milkshakeuk milkshakeuk merged commit 0b678ff into nHapiNET:master May 28, 2021
@milkshakeuk milkshakeuk linked an issue May 28, 2021 that may be closed by this pull request
@AMCN41R AMCN41R deleted the issue203 branch May 29, 2021 09:13
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.

Bad Inputs of new Parser

3 participants