Samsung / LPVS

License Pre-Validation Service analyzes which open source components and licenses are used in every patch. It returns the list of restricted licenses and the possibility of license violation on the comment with the exact code location and the open source component information.
https://samsung.github.io/LPVS/
MIT License
24 stars 26 forks source link

Exception when add empty PR or PR that contains text file only #304

Closed o-konoval closed 11 months ago

o-konoval commented 1 year ago

Describe the bug Exception appeared when add empty PR or PR that contains text file only. Empty PR- for example PR that contains 3 spaces & 3 CR. Or adding 3 spaces & 3 CR to exist file. Examples of text files in attachments:

example.txt

README.md

Input data: TITLE_SC="How to build and run LPVS from source code"; TITLE_SET_PROJ="Setting up your project to interact with LPVS"; MANUAL=https://github.com/Samsung/LPVS/blob/main/README.md

To Reproduce Steps to reproduce the behavior: 1.Follow steps 1-4 of TITLE_SC of MANUAL; 2.Check log of execution of LPVS Java application; 3.Follow steps 1-2 of TITLE_SET_PROJ of MANUAL; 4.Check ngrok started in terminal successfully.


For empty PR: 5.Make PR with adding new file in repo that contains: 3 spaces & 3CR ;

For text file1: 5.Make PR with adding new file in repo from attachment1 (example.txt) above;

For text file2: 5.Make PR with adding new file in repo from attachment2(README.md) above;


6.Check message in PR; 7.Check terminal of ngrok execution after PR; 8.Check log of LPVS Java application after PR.

Expected behavior A clear and concise description of what you expected to happen. 1.Steps 1-4 of TITLE_SC of MANUAL done; 2.Log of execution of LPVS Java application is ok; 3.Steps 1-2 of TITLE_SET_PROJ of MANUAL done; 4.Application ngrok started in terminal and log is ok. 5.PRs with adding spaces&CRs or text files done; 6.Message in PR and log is ok; 7.Terminal of ngrok execution after PR and log is ok; 8.Log of LPVS Java application is ok.

Screenshots If applicable, add screenshots to help explain your problem. Real logs for empty PR: empty_build_from_source.txt

Real logs for text PR: text_build_from_source.txt

Test environment configuration (please complete the following information):

Additional context Previously problem existed only for empty PR case.

m-rudyk commented 1 year ago

LPVS is using scanoss service to run scan via separate process.

The control of this process is performed by Java ProcessBuilder and we have limited functionality over that. below is example output of running scan on text folder: scanoss-py scan --debug --no-wfp-output -o /home/shik/Projects/Debug_LPVS/ff4ec4b5ac3babe84b0de55c85de014ca5d5eff0/result.json, /home/shik/Projects/Debug_LPVS/ff4ec4b5ac3babe84b0de55c85de014ca5d5eff0 Scan Files Scan Snippets Setting up (secure: True) connection to scanoss.com:443... Writing results to /home/shik/Projects/Debug_LPVS/ff4ec4b5ac3babe84b0de55c85de014ca5d5eff0/result.json,... Searching /home/shik/Projects/Debug_LPVS/ff4ec4b5ac3babe84b0de55c85de014ca5d5eff0 for files to fingerprint... F Root: /home/shik/Projects/Debug_LPVS/ff4ec4b5ac3babe84b0de55c85de014ca5d5eff0, Dirs: ['text_files'], Files ['result.json,'] F Root: /home/shik/Projects/Debug_LPVS/ff4ec4b5ac3babe84b0de55c85de014ca5d5eff0/text_files, Dirs: [], Files [] Warning: No files found to scan in folder: /home/shik/Projects/Debug_LPVS/ff4ec4b5ac3babe84b0de55c85de014ca5d5eff0

This result to exitCode (1) with no error description. Code snippet that handles this exit code:

if (status == 1) { log.error("Scanoss scanner terminated with none-zero code. Terminating."); BufferedReader output = null; try { output = new BufferedReader( new InputStreamReader(process.getErrorStream(), "UTF-8")); log.error(output.readLine()); throw new Exception( "Scanoss scanner terminated with none-zero code. Terminating.");

Actual log error message: 2023-11-10 15:17:04.103 ERROR 94138 --- [ LPVS-ASYNC::1] c.l.s.s.s.LPVSScanossDetectService : Scanoss scanner terminated with none-zero code. Terminating. 2023-11-10 15:17:04.103 ERROR 94138 --- [ LPVS-ASYNC::1] c.l.s.s.s.LPVSScanossDetectService : null 2023-11-10 15:17:04.126 ERROR 94138 --- [ LPVS-ASYNC::1] com.lpvs.service.LPVSQueueService : Can't authorize commentResults() java.lang.Exception: Scanoss scanner terminated with none-zero code. Terminating.

On the cntrary, when we have code files, the process finishes with exit code 0 and no error handling required.

The only solution that I can suggest:

  1. based on console output: "No files found to scan in folder:", we can ommit terminating LPVS scan
  2. Suggest change to "scanoss" repo not to exit with error in case of empty folder
m-rudyk commented 1 year ago

If we use Scanoss with option "--all-extensions", this text files will be scanned with successfull finalization. It may impact on scan time and LPVS performance.

o-kopysov commented 12 months ago

@m-rudyk First, let's try to apply --all-extensions option and measure performance. I think there will be no issues with this option.