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

Prevent absolute links from adoc to www.jenkins.io and jenkins.io #5899

Merged

Conversation

MarkEWaite
Copy link
Contributor

@MarkEWaite MarkEWaite commented Jan 9, 2023

Prevent absolute links to jenkins.io and www.jenkins.io in adoc files

When the https://www.jenkins.io/ URL is embedded in the source code of the jenkins.io pages, it causes a user exploring a pull request through the preview sites to be moved from the preview site to the www.jenkins.io site. If they are not very carefully watching the URL address bar, they can waste time looking at the production site when they wanted to review the preview site.

@ADITYADAS1999 I assumed that the issue was more difficult than you were ready to attack. If you'd like to review the technique I've used, I'd love to have comments or recommendations of ways it could be improved.

@MarkEWaite MarkEWaite requested review from a team as code owners January 9, 2023 23:54
@probot-autolabeler probot-autolabeler bot added chore documentation Jenkins documentation, including user and developer docs, solution pages, etc. governance labels Jan 9, 2023
MarkEWaite added a commit to Vandit1604/jenkins.io that referenced this pull request Jan 10, 2023
See new check that was just proposed in
jenkins-infra#5899
Copy link
Contributor

@daniel-beck daniel-beck left a comment

Choose a reason for hiding this comment

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

Please make execution of make check non-fatal on builds running on trusted.ci (or just skip it in the Jenkinsfile for env.BRANCH_NAME == null), otherwise this can block publication of security advisories.

@MarkEWaite
Copy link
Contributor Author

MarkEWaite commented Jan 10, 2023

Please make execution of make check non-fatal on builds running on trusted.ci (or just skip it in the Jenkinsfile for env.BRANCH_NAME == null), otherwise this can block publication of security advisories.

Thanks for reminding me of that case. I adapted the shell script to never fail if run on trusted.ci.jenkins.io in 185fbf8

@dduportal
Copy link
Contributor

Please make execution of make check non-fatal on builds running on trusted.ci (or just skip it in the Jenkinsfile for env.BRANCH_NAME == null), otherwise this can block publication of security advisories.

Thanks for reminding me of that case. I adapted the shell script to never fail if run on trusted.ci.jenkins.io in 185fbf8

WDYT about adding a condition on renew the signer certificate for jenkins instead?

It would use https://github.com/jenkins-infra/pipeline-library#infraistrusted :

if (!infra.isTrusted()) {
      stage('Check for typos') {
          sh 'make check'
          recordIssues(tools: [checkStyle(id: 'typos', name: 'Typos', pattern: 'checkstyle.xml')], qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]])
    }
}

Advantages:

  • Simpler shell script
  • No risk to bother contributors running the shell script locally
  • Scoped to only our environements
  • Trustable check: the pipeline-library is better source of trust than checking an environment variable

(but I might be not pointing in the correct direction, WDYT @daniel-beck ?)

@MarkEWaite
Copy link
Contributor Author

Advantages:

  • Simpler shell script
  • No risk to bother contributors running the shell script locally
  • Scoped to only our environments
  • Trustable check: the pipeline-library is better source of trust than checking an environment variable

(but I might be not pointing in the correct direction, WDYT @daniel-beck ?)

If infra.isTrusted() is already available in that context, then it is a much better choice. Checking for typographical errors and for content errors is well suited to being done in pull request evaluation and even somewhat on the master branch in the untrusted environment of ci.jenkins.io. Those checks don't make as much sense in the deployment environment, because they are advisory checks that should not block deployment.

The checks performed by `make check` are advisory.  Advisory checks
should not stop a deployment from trusted.ci.jenkins.io.
Jenkinsfile Outdated
@@ -49,8 +49,11 @@ node('docker&&linux') {
}

stage('Check for typos') {
sh 'make check'
recordIssues(tools: [checkStyle(id: 'typos', name: 'Typos', pattern: 'checkstyle.xml')], qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]])
if (!infra.isTrusted()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Inconsistent with

if (env.BRANCH_NAME == null) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Included in d67b1ba with a comment to clarify why two conditions are being checked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@daniel-beck does the change in d67b1ba address your concerns enough that this can be merged or are more changes required?

Use same terms in the conditional in both places.
MarkEWaite added a commit to gounthar/jenkins.io that referenced this pull request Jan 11, 2023
See jenkins-infra#5899 and
jenkins-infra#5718 for the
detailed reasons why we want to keep the hostname out of the links of
the jenkins.io docuemntation
@dduportal dduportal enabled auto-merge January 14, 2023 12:22
@dduportal dduportal disabled auto-merge January 14, 2023 12:22
@dduportal
Copy link
Contributor

Please make execution of make check non-fatal on builds running on trusted.ci (or just skip it in the Jenkinsfile for env.BRANCH_NAME == null), otherwise this can block publication of security advisories.

Ping @daniel-beck , is it ok for you (as GitHub indicates "Merging can be performed automatically once the requested changes are addressed.")?

* Checks are advisory only.
* They are intentionally skipped when preparing a deployment.
*/
if (!infra.isTrusted() && env.BRANCH_NAME != null) {

Choose a reason for hiding this comment

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

Where is this infra.isTrusted defined?
I was just looking around.

Choose a reason for hiding this comment

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

Here: https://github.com/jenkins-infra/pipeline-library/blob/master/vars/infra.groovy

It allows to determine if the current build is run from trusted.ci.jenkins.io or not.

Copy link

Choose a reason for hiding this comment

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

Thank you for explaining that. I have one follow up question. So basically we are importing that from another repository. I have imported groovyscript in the same repo by using load "path to script" but here how is this import from different repo done?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore documentation Jenkins documentation, including user and developer docs, solution pages, etc. governance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent absolute links to jenkins.io or www.jenkins.io and use relative instead
7 participants