Skip to content

Conversation

@wschaeferB
Copy link
Contributor

Making PR now to start working on what I expect to be many Codacy complaints

William Schaefer added 27 commits May 9, 2019 15:19
@wschaeferB
Copy link
Contributor Author

closing PR till I finish clean up since codacy seems to be somewhat satisfied

@wschaeferB wschaeferB closed this May 13, 2019
@wschaeferB
Copy link
Contributor Author

Should be ready to review.

@wschaeferB wschaeferB reopened this May 14, 2019
@rcordovano rcordovano requested review from dannysmyda and eugene7646 and removed request for dannysmyda May 16, 2019 16:12
try {
content.read(data, 0x0, content.getSize());
} catch (TskCoreException ex) {
logger.log(Level.WARNING, "Failed to read file content.", ex);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we exit here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returning there sounds like a reasonable thing to do if the reading of the data fails. It wasn't being done in the original code I was integrating, but that is no indication it shouldn't be done. I will make this change and test to ensure it works, unless I hear otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really know what the right answer is so you should probably seek the opinion of @rcordovano.

try {
file.read(header, 0x0, Math.min(0x4000, file.getSize()));
} catch (TskCoreException ex) {
logger.log(Level.WARNING, "Failed to read file content", ex);
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess same question, shouldn't we exit if there was an exception while trying to read data from the file? Is there a point in trying to continue and to pass incomplete/gibberish data to other classes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same answer, I have no idea if there is a point.

}

// the number of line endings before the start,end points
int startRows = (startByte - (startByte % bytesPerLine)) / (3 * bytesPerLine);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably make the "3" into a constant, since we are using it in multiple places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

} else {
sb.append(valString);
}
if (sb.length() > 48) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also make constants out of these, I would have no idea what 45 or 48 is if I had to debug the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, the constants might be a bit vague in name like "MAX_VALUE_STRING_LEN" or something like that but I agree even vaguely named constants would be easier to understand than the raw numbers.

@eugene7646
Copy link
Contributor

I have finished the review and testing. As soon as the minor code review things are taken care of - the PR is good to go.

@rcordovano rcordovano merged commit f6c4776 into sleuthkit:develop May 28, 2019
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.

3 participants