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

hotfix: Add lesmis la is valid url to pdf exporter #4062

Merged
merged 3 commits into from
Aug 1, 2022

Conversation

biaoli0
Copy link
Contributor

@biaoli0 biaoli0 commented Aug 1, 2022

Issue #:

pdf export is broken in lesmis.la

@@ -39,7 +39,7 @@ rm -rf lastpass-cli
mkdir -p /home/ubuntu/.local/share/lpass

# install puppeteer dependencies https://pptr.dev/15.3.0/troubleshooting#chrome-headless-doesnt-launch-on-unix
sudo apt-get -y install \
sudo apt-get -yqq install \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

dependencies didn't install in gold master, see if this will fix.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious to know why adding qq to the args would fix it? Doesn't that just affect logging?

@biaoli0 biaoli0 force-pushed the add-lesmis-la-is-valid-url-to-pdf-exporter branch from 303724e to dac846b Compare August 1, 2022 04:53
@biaoli0 biaoli0 force-pushed the add-lesmis-la-is-valid-url-to-pdf-exporter branch from dac846b to 0fcee53 Compare August 1, 2022 05:07
Comment on lines +43 to +57
ca-certificates \
fonts-liberation \
libappindicator3-1 \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgbm1 \
libgcc1 \
libglib2.0-0 \
Copy link
Contributor Author

@biaoli0 biaoli0 Aug 1, 2022

Choose a reason for hiding this comment

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

@rohan-bes And also one space in front of each dependency for fixing it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahh whitespace issues, I love em 😂 😭

Copy link
Collaborator

@rohan-bes rohan-bes left a comment

Choose a reason for hiding this comment

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

Minor code readability change, but aside from that looks good to me 👍

@@ -38,12 +38,17 @@ export class PDFExportRoute extends Route<PDFExportRequest> {
};

private verifyBody = (body: any): Body => {
const legitLESMISHostnames = ['lesmis.la', 'www.lesmis.la'];
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd suggest having an explicit list of the domains that Tupaia supports

Suggested change
const legitLESMISHostnames = ['lesmis.la', 'www.lesmis.la'];
const validDomains= ['.tupaia.org', '.lesmis.la'];

And then later do:

if (!validDomains.some(domain=> location.hostname.endsWith(domain)) && !location.hostname.endsWith('localhost')) {

Might even be best to store this list of valid hostnames in a utils file/function somewhere, but I can't see another area in the code where do we such a check, so it seems okay to me for it to be here for now 👍

Copy link
Contributor Author

@biaoli0 biaoli0 Aug 1, 2022

Choose a reason for hiding this comment

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

Thanks for the renaming suggestion.
This check is for security, because pdf-export-server will access the provided pdfPageUrl from puppeteer headless browser, and without this check, hacker could easily get user's session by a malicious link from the pdfPageUrl.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just found that we have to keep lesmis.la because it is a legit DNS for lesmis as well.

@rohan-bes
Copy link
Collaborator

@billli0 you know the drill when it comes to making changes to the setupGoldMaster.sh file? How you have to import it to s3 and manually kick off a build

@biaoli0
Copy link
Contributor Author

biaoli0 commented Aug 1, 2022

@rohan-bes Yes I know how to update this file in s3, but I don't have permission to kick off a build. Could you grant me the access?

@rohan-bes
Copy link
Collaborator

@billli0 okay have bumped your permissions, wanna give it another shot?

@biaoli0 biaoli0 merged commit 4fccb18 into master Aug 1, 2022
@biaoli0 biaoli0 deleted the add-lesmis-la-is-valid-url-to-pdf-exporter branch August 1, 2022 22:47
@biaoli0
Copy link
Contributor Author

biaoli0 commented Aug 2, 2022

Thanks @rohan-bes, it works!

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.

2 participants