Skip to content

Commit

Permalink
Merge pull request #1860 from TryQuiet/pr-hotfix-file-download-and-gi…
Browse files Browse the repository at this point in the history
…thub

Backport .github changes and file download hotfix
  • Loading branch information
Lucas Leblow authored Sep 25, 2023
2 parents bb9b417 + 03105fe commit 02f6742
Show file tree
Hide file tree
Showing 13 changed files with 248 additions and 32 deletions.
108 changes: 108 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly

- package-ecosystem: docker
directory: /3rd-party/tor
schedule:
interval: weekly

- package-ecosystem: npm
directory: /
schedule:
interval: weekly

- package-ecosystem: npm
directory: /packages/backend-bundle
schedule:
interval: weekly

- package-ecosystem: docker
directory: /packages/backend
schedule:
interval: weekly

- package-ecosystem: npm
directory: /packages/backend
schedule:
interval: weekly

- package-ecosystem: npm
directory: /packages/common
schedule:
interval: weekly

- package-ecosystem: npm
directory: /packages/desktop
schedule:
interval: weekly

- package-ecosystem: docker
directory: /packages/e2e-tests/docker
schedule:
interval: weekly

- package-ecosystem: npm
directory: /packages/e2e-tests
schedule:
interval: weekly

- package-ecosystem: npm
directory: /packages/eslint-config-custom
schedule:
interval: weekly

- package-ecosystem: npm
directory: /packages/identity
schedule:
interval: weekly

# Currently, the integration tests pkg is waiting for a clean up.
# @SEE: https://github.com/TryQuiet/quiet/pull/1734#discussion_r1302831794
# - package-ecosystem: docker
# directory: /packages/integration-tests
# schedule:
# interval: weekly

# - package-ecosystem: npm
# directory: /packages/integration-tests
# schedule:
# interval: weekly

- package-ecosystem: npm
directory: /packages/logger
schedule:
interval: weekly

- package-ecosystem: bundler
directory: /packages/mobile
schedule:
interval: weekly

- package-ecosystem: docker
directory: /packages/mobile/android-environment
schedule:
interval: weekly

- package-ecosystem: npm
directory: /packages/mobile/nodejs-modules/builtin_modules/rn-bridge
schedule:
interval: weekly

- package-ecosystem: npm
directory: /packages/mobile
schedule:
interval: weekly

- package-ecosystem: npm
directory: /packages/state-manager
schedule:
interval: weekly

- package-ecosystem: npm
directory: /packages/types
schedule:
interval: weekly
5 changes: 5 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

### Pull Request Checklist

- [ ] I have linked this PR to related GitHub issue.
- [ ] I have updated the CHANGELOG.md file with relevant changes (the file is located at the root of monorepo).
Binary file removed .github/secrets/CI.mobileprovision.gpg
Binary file not shown.
Binary file modified .github/secrets/Certificates.p12.gpg
Binary file not shown.
4 changes: 2 additions & 2 deletions .github/secrets/decrypt_secrets.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/sh

gpg --quiet --batch --yes --decrypt --passphrase="$IOS_PROFILE_KEY" --output ./.github/secrets/CI.mobileprovision ./.github/secrets/CI.mobileprovision.gpg
gpg --quiet --batch --yes --decrypt --passphrase="$IOS_PROFILE_KEY" --output ./.github/secrets/match_AppStore_comquietmobile.mobileprovision ./.github/secrets/match_AppStore_comquietmobile.mobileprovision.gpg
gpg --quiet --batch --yes --decrypt --passphrase="$IOS_CERTIFICATE_KEY" --output ./.github/secrets/Certificates.p12 ./.github/secrets/Certificates.p12.gpg

mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles

cp ./.github/secrets/CI.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/654a2214-095f-4939-a9e5-09f7a2ccf530.mobileprovision
cp ./.github/secrets/match_AppStore_comquietmobile.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/654a2214-095f-4939-a9e5-09f7a2ccf530.mobileprovision


security create-keychain -p "" build.keychain
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: ./.github/workflows/e2e-win.yml

build-linux:
needs: run-e2e-tests-linux
# needs: run-e2e-tests-linux
runs-on: ubuntu-22.04
if: |
startsWith(github.ref, 'refs/tags/quiet')
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
asset_content_type: application/.AppImage

build-macos:
needs: run-e2e-tests-mac
# needs: run-e2e-tests-mac
runs-on: macos-latest
if: |
startsWith(github.ref, 'refs/tags/quiet')
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: ["develop"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["develop"]
schedule:
- cron: "0 0 * * 1"

permissions:
contents: read

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ["javascript", "python", "ruby", "typescript"]
# CodeQL supports [ $supported-codeql-languages ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@a09933a12a80f87b87005513f0abb1494c27a716 # v2.21.4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@a09933a12a80f87b87005513f0abb1494c27a716 # v2.21.4

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@a09933a12a80f87b87005513f0abb1494c27a716 # v2.21.4
with:
category: "/language:${{matrix.language}}"
22 changes: 22 additions & 0 deletions .github/workflows/depencency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Dependency Review Action
#
# This Action will scan dependency manifest files that change as part of a Pull Request,
# surfacing known-vulnerable versions of the packages declared or updated in the PR.
# Once installed, if the workflow run is marked as required,
# PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: 'Dependency Review'
uses: actions/dependency-review-action@0efb1d1d84fc9633afcdaad14c485cbbc90ef46c # v2.5.1
18 changes: 8 additions & 10 deletions .github/workflows/deploy-android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@ jobs:
- name: "Build for Android"
run: cd ./packages/mobile/android && ENVFILE=../.env.production ./gradlew bundleStandardRelease

# Temporary disable, failing on CI
# - name: "Upload Artifact"
# continue-on-error: true
# uses: actions/upload-artifact@v2
# with:
# name: app-standard-release.aab
# path: ./packages/mobile/android/app/build/outputs/bundle/standardRelease/app-standard-release.aab
# retention-days: 5
- name: "Upload Artifact"
continue-on-error: true
uses: actions/upload-artifact@v2
with:
name: app-standard-release.aab
path: ./packages/mobile/android/app/build/outputs/bundle/standardRelease/app-standard-release.aab
retention-days: 5

- name: "Configure Google Play upload"
run: |
Expand All @@ -79,12 +78,11 @@ jobs:
echo ${{ SECRETS.SERVICE_ACCOUNT_JSON }} | base64 --decode > google-play.json
- name: "Upload to Google Play"
uses: r0adkll/upload-google-play@v1.0.17
uses: r0adkll/upload-google-play@v1.1.2
with:
serviceAccountJson: google-play.json
packageName: com.quietmobile
releaseFiles: ./packages/mobile/android/app/build/outputs/bundle/standardRelease/app-standard-release.aab
status: completed
track: internal
whatsNewDirectory: distribution/whatsnew
changesNotSentForReview: true
26 changes: 13 additions & 13 deletions .github/workflows/e2e-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ jobs:
uses: nick-fields/retry@v2
with:
timeout_minutes: 25
max_attempts: 3
max_attempts: 1
command: cd packages/e2e-tests && npm run test invitationLink.test.ts

# - name: Download App Image 1.2.0
# working-directory: ./packages/e2e-tests/Quiet
# run: curl -LO https://github.com/TryQuiet/quiet/releases/download/quiet%401.2.0/Quiet-1.2.0.AppImage
- name: Download App Image 1.2.0
working-directory: ./packages/e2e-tests/Quiet
run: curl -LO https://github.com/TryQuiet/quiet/releases/download/quiet%401.2.0/Quiet-1.2.0.AppImage

# - name: Chmod App Image 1.2.0
# working-directory: ./packages/e2e-tests/Quiet
# run: chmod +x Quiet-1.2.0.AppImage
- name: Chmod App Image 1.2.0
working-directory: ./packages/e2e-tests/Quiet
run: chmod +x Quiet-1.2.0.AppImage

# - name: Run Backwards Compatibility test
# uses: nick-fields/retry@v2
# with:
# timeout_minutes: 15
# max_attempts: 3
# command: cd packages/e2e-tests && npm run test backwardsCompatibility.test.ts
- name: Run Backwards Compatibility test
uses: nick-fields/retry@v2
with:
timeout_minutes: 15
max_attempts: 3
command: cd packages/e2e-tests && npm run test backwardsCompatibility.test.ts
2 changes: 2 additions & 0 deletions .github/workflows/e2e-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on: [workflow_call]
jobs:
windows:
runs-on: windows-2019

timeout-minutes: 180

env:
ELECTRON_CUSTOM_VERSION: 23.0.0
TEST_MODE: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Inject, Injectable } from '@nestjs/common'
import { EventEmitter, setMaxListeners } from 'events'
import fs from 'fs'
import path from 'path'
import crypto from 'crypto'
import PQueue, { AbortError } from 'p-queue'
import { decode, PBNode } from '@ipld/dag-pb'
import * as base58 from 'multiformats/bases/base58'
Expand Down Expand Up @@ -433,13 +434,20 @@ export class IpfsFileManagerService extends EventEmitter {
private async assemblyFile(fileMetadata: FileMetadata) {
const _CID = CID.parse(fileMetadata.cid)

const downloadDirectory = path.join(this.quietDir, 'downloads', fileMetadata.cid)
const downloadDirectory = path.join(this.quietDir, 'downloads')
createPaths([downloadDirectory])

const fileName = fileMetadata.name + fileMetadata.ext
const filePath = `${path.join(downloadDirectory, fileName)}`

const writeStream = fs.createWriteStream(filePath)
// As a quick fix, using a UUID for filename ensures that we never
// save a file with a malicious filename. Perhaps it's also
// possible to use the CID, however let's verify that first.
let fileName: string
let filePath: string
do {
fileName = crypto.randomUUID()
filePath = `${path.join(downloadDirectory, fileName)}`
} while (fs.existsSync(filePath))

const writeStream = fs.createWriteStream(filePath, { flags: 'wx' })

const entries = this.ipfs.cat(_CID)

Expand Down

0 comments on commit 02f6742

Please sign in to comment.