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

Since the Cobertura coverage-04.dtd document URL is http, sonar-scanner cannot format it #558

Closed
turkcankeskin opened this issue May 27, 2024 · 2 comments · Fixed by #559

Comments

@turkcankeskin
Copy link

I'm scanning my iOS project with sonar-swift.sh using sonarqube.

slather coverage --input-format profdata --cobertura-xml --output-directory sonar-reports --workspace test.xcworkspace --scheme test test.xcodeproj

It gives Cobertura XML Output directly in my cobertura.xml output.

<?xml version="1.0"?><!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">

But later when I run sonar-scanner

sonar-scanner -Dsonar.host.url=https://sonarqube.xxx.com/ -Dsonar.login=**** -Dsonar.projectKey=test -Dsonar.qualitygate.wait=true -Dsonar.qualitygate.timeout=600 --define sonar.projectVersion=19.2.0

It gives an error as an exception. I think "https://cobertura.sourceforge.net/xml/coverage-04.dtd" should be used here instead of "http://cobertura.sourceforge.net/xml/coverage-04.dtd"

Is there a parameter for https when creating cobertura.xml in slather?
because http://cobertura.sourceforge.net/xml/coverage-04.dtd is a 301 redirect.

17:06:05 INFO: Processing Cobertura report sonar-reports/coverage-swift.xml
17:06:05 [Fatal Error] coverage-04.dtd:1:2: The markup declarations contained or pointed to by the document type declaration must be well-formed.
17:06:05 ERROR: Error processing file named sonar-reports/coverage-swift.xml
17:06:05 org.xml.sax.SAXParseException: The markup declarations contained or pointed to by the document type declaration must be well-formed.
17:06:05 at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:261)
17:06:05 at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
17:06:05 at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:206)
17:06:05 at com.backelite.sonarqube.swift.coverage.CoberturaReportParser.parseReport(CoberturaReportParser.java:60)
17:06:05 at com.backelite.sonarqube.swift.coverage.CoberturaSensor.execute(CoberturaSensor.java:69)
17:06:05 at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
17:06:05 at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
17:06:05 at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
17:06:05 at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
17:06:05 at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
17:06:05 at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
17:06:05 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
17:06:05 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
17:06:05 at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:392)
17:06:05 at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
17:06:05 at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
17:06:05 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
17:06:05 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
17:06:05 at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:150)
17:06:05 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
17:06:05 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
17:06:05 at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
17:06:05 at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
17:06:05 at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
17:06:05 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
17:06:05 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
17:06:05 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
17:06:05 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
17:06:05 at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
17:06:05 at com.sun.proxy.$Proxy0.execute(Unknown Source)
17:06:05 at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
17:06:05 at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
17:06:05 at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
17:06:05 at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
17:06:05 at org.sonarsource.scanner.cli.Main.main(Main.java:61)

@jarrodlombardo-EventBase
Copy link
Contributor

That is very subtle. I think it should probably always just use https.

ksuther added a commit that referenced this issue May 27, 2024
…base/fix-558

Fix #558: cobertura.sourceforge.net should use https instead of http.
@jarrodlombardo-EventBase
Copy link
Contributor

The change to https was good, but the url is still 404. I've found the correct url (https://raw.githubusercontent.com/cobertura/cobertura/master/cobertura/src/site/htdocs/xml/coverage-04.dtd) , but will need to submit a new PR to update it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants