As we will use new entity for broken links, we have to create new reports pages using Views.

There are should be available such sort options:

  • by Last checked time
  • by Status code
  • Check link status

There are should be available such filter options:

  • by URL
  • by Status code
  • by Entity
  • by Language

Comments

pnagornyak created an issue. See original summary.

pnagornyak’s picture

StatusFileSize
new30.32 KB

Added a view.

pnagornyak’s picture

StatusFileSize
new50.43 KB

Remove some controllers and code for old report pages. I suppose, we no longer need them, but I added it as another patch to easily revert it.

hass’s picture

Priority: Major » Normal

Yes, need to be migrated to views. Where are you checking if the user has permission to view a link?

pnagornyak’s picture

pnagornyak’s picture

StatusFileSize
new30.14 KB
new21.42 KB
pnagornyak’s picture

StatusFileSize
new50.24 KB
new19.57 KB
hass’s picture

Status: Active » Needs review

I guess this needs a rerole after the many other commits?

waverate’s picture

StatusFileSize
new20.11 KB

Re-roll of patch at #7 against linkchecker-8.x-1.x-dev (29 May 2019).

waverate’s picture

StatusFileSize
new20.11 KB

Forgot to add the view.

waverate’s picture

StatusFileSize
new50.25 KB

Sigh.

waverate’s picture

StatusFileSize
new50.24 KB

Moved /config/optional/views.view.broken_links_report.yml to /config/install/views.view.broken_links_report.yml

waverate’s picture

Use patch at #11.

From CR:

If a module, theme or profile provides configuration that has additional dependencies that might not be met during its installation then this configuration should be stored in config/optional. For example, the Node module provides the frontpage view. The Node module does not depend on Views. Therefore, views.view.frontpage.yml must be stored in Node's config/optional directory.

waverate’s picture

StatusFileSize
new50.26 KB

1. Re-roll patch at #11 against linkchecker-8.x-1.x-dev (29 May 2019) - 5fcf109d

2. Fixed views broken/missing handler for Entity Field.

3. Enabled contextual link in view.

Now that the report is available in views, I think the rest of the customizations can be done by the end user to fit their needs.

waverate’s picture

hass’s picture

Once the reports are migrated to views - linkchecker depends on views.

We cannot commit this view as it adds a security bug. perm: 'access broken links report' Is not correct. The user that views the view may not allowed to see a content type field a link is extracted from. Such links may contain passwords what will cause security bypass to users with ‚access broken links report' permission.

Since we know now from what entity the link comes from, we could check the field permission of the current user has access too and exclude these links from the report.

waverate’s picture

Re: #16. Is adding text to the permission acceptable for now or maybe calling the permission View Any Broken links report?

Warning: Give to trusted roles only; this permission has security implications.

This may allow you to commit this patch and keep the D8 release moving forward.

We can then open a new issue to create View Own Broken links report; or something similar.

pnagornyak’s picture

@waverate have you checked on your local env that it is bypassing entity access?
we have an Access Handler for LinkCheckerLink and it should work, so there is no need to add restricted permission warning.
Please check it.

waverate’s picture

StatusFileSize
new199.09 KB

Re: #18. Sorry. I didn’t realise you already implemented the permissions in linkchecker.permissions.yml:

Broken Link Report Permissions

1. I think @hass is correct. The ‘Access broken links report’ permission should have restrict access: true.

2. With respect to linkchecker.routing.yml, are the report permissions taken care of here or are they part of the view:

linkchecker.admin_report_page:
  path: '/admin/reports/linkchecker'
  defaults:
    _controller: '\Drupal\linkchecker\Controller\LinkCheckerAdminReportPage::content'
    _title: 'Broken links'
  requirements:
    _permission: 'access broken links report'

linkchecker.user_report_page:
  path: '/user/{user}/linkchecker'
  defaults:
    _title: 'Broken links'
    _controller: '\Drupal\linkchecker\Controller\LinkCheckerUserReportPage::content'
  options:
    _admin_route: TRUE
  requirements:
    _custom_access: '\Drupal\linkchecker\Controller\LinkCheckerUserReportPage::access'
    user: \d+

3. I don’t see the the view display for /user/{user}/linkchecker. Should I build that?

waverate’s picture

hass’s picture

@pnagornyak: Can we prove the entity permission works properly with a test, please?

I don’t see the the view display for /user/{user}/linkchecker. Should I build that?

Yes, but we should handle this in an extra case so that this case here does not get blocked by it.

waverate’s picture

Re: #18. I can confirm in my local env, that I have given a user without any nodes/entities, only permission ‘Access broken links report’.

The user has access to all links in the Broken links report.

How is the access handler supposed to be used in the view?

waverate’s picture

Status: Needs review » Needs work
pnagornyak’s picture

StatusFileSize
new54.66 KB
new39.08 KB

I checked how Views checks access to entity - there is no entity access check :(
But Views checks field access, so I adjusted fieldAccess for LinkcheckerLink URL field, if user does not have access to entity that stores a Link then he will see empty URL in table, here is example:
https://i.imgur.com/Cnqnbpr.png

NOTE: if we will add access check on view prerender hook, then user will see broken list of links, means - on some pages he will see 20 links, on some pages 6 or even 0 (in a case if view pager is exist).

I also add some adjustments access handler and tests, for cases when parent entity was removed but Link still exists in database.

pnagornyak’s picture

Status: Needs work » Needs review
waverate’s picture

Patch at #24 looks good. I also think @pnagornyak's interpretation of @hass' requirement at #4 is a good one.

Instead of:

checking if the user has permission to view a link

Check if users have view access to field containing a link.

If a user does not have view access to the field containing a link, he will not see the URL in the Report as shown in @pnagornyak's attached image.

Are we able to filter the View if URL is empty, so a user will not see these rows at all? If that could be done, I'd call this perfect.

hass’s picture

Can we add a text like "Permission restrictions deny you access to this broken link." (as in D7) as replacement to no URL?

  • hass committed 3554383 on 8.x-1.x authored by pnagornyak
    Issue #2992604 by pnagornyak, waverate: Broken links report
hass’s picture

Status: Needs review » Fixed

I committed this as-is in hope it is done correctly. Lets fix the remaining stuff in follow ups.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.