Upgrading STF for security reasons (#813)

* Upgrading STF for security reasons

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>

* update semaphore files

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>

* upgrading STF for security reasons v2

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>

* update yarn.lock file

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>

---------

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>
This commit is contained in:
Denis Barbaron
2024-11-22 11:41:20 +01:00
committed by GitHub
parent e204b03661
commit 2f54e40206
48 changed files with 2443 additions and 1167 deletions

2
.nvmrc
View File

@@ -1 +1 @@
17.9.0
v22.11.0

View File

@@ -7,7 +7,7 @@ blocks:
- name: Deploy
commands:
- install-package libzmq3-dev libprotobuf-dev graphicsmagick yasm gulp python3
- sem-version node 17.9.0
- sem-version node 20
- checkout
- npm install
- npm publish --access=public

View File

@@ -20,7 +20,7 @@ blocks:
- name: npm test
commands:
- install-package libzmq3-dev libprotobuf-dev graphicsmagick yasm gulp python3
- sem-version node 17.9.0
- sem-version node 20
- checkout
- npm install
- npm test

View File

@@ -1 +1 @@
nodejs 17.9.0
nodejs 22.11.0

View File

@@ -1,11 +1,11 @@
#
# Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
# Copyright © 2022-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
#
FROM ubuntu:20.04
FROM ubuntu:22.04
# Sneak the stf executable into $PATH.
ENV PATH /app/bin:$PATH
ENV PATH=/app/bin:$PATH
# Work in app dir by default.
WORKDIR /app
@@ -28,15 +28,18 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
--shell /usr/sbin/nologin \
stf && \
sed -i'' 's@http://archive.ubuntu.com/ubuntu/@mirror://mirrors.ubuntu.com/mirrors.txt@' /etc/apt/sources.list && \
echo '--- Updating repositories' && \
apt-get update && \
echo '--- Upgrading repositories' && \
apt-get -y dist-upgrade && \
apt-get -y install wget python3 build-essential && \
cd /tmp && \
wget --progress=dot:mega \
https://nodejs.org/dist/v17.9.0/node-v17.9.0-linux-x64.tar.xz && \
https://nodejs.org/dist/v22.11.0/node-v22.11.0-linux-x64.tar.xz && \
tar -xJf node-v*.tar.xz --strip-components 1 -C /usr/local && \
rm node-v*.tar.xz && \
su stf-build -s /bin/bash -c '/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js install' && \
apt-get -y install libzmq3-dev libprotobuf-dev git graphicsmagick openjdk-8-jdk yasm cmake && \
apt-get -y install --no-install-recommends libzmq3-dev libprotobuf-dev git graphicsmagick openjdk-8-jdk yasm cmake && \
apt-get clean && \
rm -rf /var/cache/apt/* /var/lib/apt/lists/* && \
mkdir /tmp/bundletool && \
@@ -57,22 +60,29 @@ USER stf-build
# Run the build.
RUN set -x && \
echo '--- Building app' && \
cd /tmp/build && \
export PATH=$PWD/node_modules/.bin:$PATH && \
npm install --python="/usr/bin/python3" --loglevel http && \
npm install --python="/usr/bin/python3" --omit=optional --loglevel http && \
echo '--- Assembling app' && \
npm pack && \
tar xzf devicefarmer-stf-*.tgz --strip-components 1 -C /app && \
bower cache clean && \
npm prune --production && \
npm prune --omit=dev && \
mv node_modules /app && \
rm -rf ~/.node-gyp && \
mkdir /app/bundletool && \
mv /tmp/bundletool/* /app/bundletool && \
cd /app && \
find /tmp -mindepth 1 ! -regex '^/tmp/hsperfdata_root\(/.*\)?' -delete
find /tmp -mindepth 1 ! -regex '^/tmp/hsperfdata_root\(/.*\)?' -delete && \
rm -rf doc .github .tx .semaphore *.md *.yaml LICENSE Dockerfile* \
.eslintrc .nvmrc .tool-versions res/.eslintrc && \
cd && \
rm -rf .npm .cache .config .local && \
cd /app
# Switch to the app user.
USER stf
# Show help by default.
CMD stf --help
CMD ["stf", "--help"]

View File

@@ -1,8 +1,8 @@
#
# Copyright © 2020,2022 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
# Copyright © 2020-2024 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
#
FROM arm64v8/debian:buster-slim
FROM arm64v8/debian:bookworm-slim
LABEL Maintainer="Denis Barbaron <denis.barbaron@orange.com>"
LABEL Name="STF"
@@ -10,7 +10,7 @@ LABEL Url="https://github.com/devicefarmer/stf/"
LABEL Description="STF docker image for arm64 architecture"
# Sneak the stf executable into $PATH.
ENV PATH /app/bin:$PATH
ENV PATH=/app/bin:$PATH
# Work in app dir by default.
WORKDIR /app
@@ -18,15 +18,17 @@ WORKDIR /app
# Copy app source.
COPY . /tmp/build/
# Install app requirement
# Install app requirements
RUN export DEBIAN_FRONTEND=noninteractive && \
echo '--- Updating repositories' && \
apt-get update && \
echo '--- Upgrading repositories' && \
apt-get -y dist-upgrade && \
echo '--- Building node' && \
apt-get -y install wget python3 build-essential cmake && \
apt-get -y install pkg-config curl zip unzip wget python3 build-essential cmake ninja-build && \
cd /tmp && \
wget --progress=dot:mega \
https://nodejs.org/dist/v17.9.0/node-v17.9.0-linux-arm64.tar.xz && \
https://nodejs.org/dist/v22.11.0/node-v22.11.0-linux-arm64.tar.xz && \
tar -xJf node-v*.tar.xz --strip-components 1 -C /usr/local && \
rm node-v*.tar.xz && \
useradd --system \
@@ -42,26 +44,32 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
cd /tmp/build && \
export PATH=$PWD/node_modules/.bin:$PATH && \
sed -i'' -e '/phantomjs/d' package.json && \
echo 'npm install --python="/usr/bin/python3" --no-optional --loglevel http' | su stf -s /bin/bash && \
export VCPKG_FORCE_SYSTEM_BINARIES="arm" && \
echo 'npm install --save-dev pnpm' | su stf -s /bin/bash && \
echo 'npm install --python="/usr/bin/python3" --omit=optional --loglevel http' | su stf -s /bin/bash && \
echo '--- Assembling app' && \
echo 'npm pack' | su stf -s /bin/bash && \
tar xzf devicefarmer-stf-*.tgz --strip-components 1 -C /app && \
echo '/tmp/build/node_modules/.bin/bower cache clean' | su stf -s /bin/bash && \
echo 'npm prune --production' | su stf -s /bin/bash && \
echo 'npm prune --omit=dev' | su stf -s /bin/bash && \
mv node_modules /app && \
chown -R root:root /app && \
echo '--- Cleaning up' && \
echo 'npm cache clean --force' | su stf -s /bin/bash && \
rm -rf ~/.node-gyp && \
apt-get -y purge wget python3 build-essential && \
apt-get -y purge pkg-config curl zip unzip wget python3 build-essential cmake ninja-build && \
apt-get -y clean && \
apt-get -y autoremove && \
cd /home/stf && \
rm -rf vcpkg .npm .cache .cmake-ts .config .local && \
rm -rf /var/cache/apt/* /var/lib/apt/lists/* && \
cd /app && \
rm -rf doc .github .tx .semaphore *.md *.yaml LICENSE Dockerfile* \
.eslintrc .nvmrc .tool-versions res/.eslintrc && \
rm -rf /tmp/*
# Switch to the app user.
USER stf
# Show help by default.
CMD stf --help
CMD ["stf", "--help"]

View File

@@ -1,8 +1,8 @@
#
# Copyright © 2020,2022 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
# Copyright © 2020-2024 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
#
FROM arm32v7/debian:buster-slim
FROM arm32v7/debian:bookworm-slim
LABEL Maintainer="Denis Barbaron <denis.barbaron@orange.com>"
LABEL Name="STF"
@@ -10,7 +10,7 @@ LABEL Url="https://github.com/devicefarmer/stf/"
LABEL Description="STF docker image for armhf architecture"
# Sneak the stf executable into $PATH.
ENV PATH /app/bin:$PATH
ENV PATH=/app/bin:$PATH
# Work in app dir by default.
WORKDIR /app
@@ -18,15 +18,17 @@ WORKDIR /app
# Copy app source.
COPY . /tmp/build/
# Install app requirement
# Install app requirements
RUN export DEBIAN_FRONTEND=noninteractive && \
echo '--- Updating repositories' && \
apt-get update && \
echo '--- Upgrading repositories' && \
apt-get -y dist-upgrade && \
echo '--- Building node' && \
apt-get -y install wget python3 build-essential cmake && \
apt-get -y install pkg-config curl zip unzip wget python3 build-essential cmake ninja-build && \
cd /tmp && \
wget --progress=dot:mega \
https://nodejs.org/dist/v17.9.0/node-v17.9.0-linux-armv7l.tar.xz && \
https://nodejs.org/dist/v22.11.0/node-v22.11.0-linux-armv7l.tar.xz && \
tar -xJf node-v*.tar.xz --strip-components 1 -C /usr/local && \
rm node-v*.tar.xz && \
useradd --system \
@@ -34,7 +36,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
--shell /usr/sbin/nologin \
stf && \
su stf -s /bin/bash -c '/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js install' && \
apt-get -y install --no-install-recommends libzmq3-dev libprotobuf-dev git graphicsmagick yasm && \
apt-get -y install --no-install-recommends libatomic1 libzmq3-dev libprotobuf-dev git graphicsmagick yasm && \
echo '--- Building app' && \
mkdir -p /app && \
chown -R stf:stf /tmp/build && \
@@ -42,26 +44,32 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
cd /tmp/build && \
export PATH=$PWD/node_modules/.bin:$PATH && \
sed -i'' -e '/phantomjs/d' package.json && \
echo 'npm install --python="/usr/bin/python3" --no-optional --loglevel http' | su stf -s /bin/bash && \
export VCPKG_FORCE_SYSTEM_BINARIES="arm" && \
echo 'npm install --save-dev pnpm' | su stf -s /bin/bash && \
echo 'npm install --python="/usr/bin/python3" --omit=optional --loglevel http' | su stf -s /bin/bash && \
echo '--- Assembling app' && \
echo 'npm pack' | su stf -s /bin/bash && \
tar xzf devicefarmer-stf-*.tgz --strip-components 1 -C /app && \
echo '/tmp/build/node_modules/.bin/bower cache clean' | su stf -s /bin/bash && \
echo 'npm prune --production' | su stf -s /bin/bash && \
echo 'npm prune --omit=dev' | su stf -s /bin/bash && \
mv node_modules /app && \
chown -R root:root /app && \
echo '--- Cleaning up' && \
echo 'npm cache clean --force' | su stf -s /bin/bash && \
rm -rf ~/.node-gyp && \
apt-get -y purge wget python3 build-essential && \
apt-get -y purge pkg-config curl zip unzip wget python3 build-essential cmake ninja-build && \
apt-get -y clean && \
apt-get -y autoremove && \
cd /home/stf && \
rm -rf vcpkg .npm .cache .cmake-ts .config .local && \
rm -rf /var/cache/apt/* /var/lib/apt/lists/* && \
cd /app && \
rm -rf doc .github .tx .semaphore *.md *.yaml LICENSE Dockerfile* \
.eslintrc .nvmrc .tool-versions res/.eslintrc && \
rm -rf /tmp/*
# Switch to the app user.
USER stf
# Show help by default.
CMD stf --help
CMD ["stf", "--help"]

View File

@@ -1,8 +1,8 @@
#
# Copyright © 2020,2022 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
# Copyright © 2020-2024 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
#
FROM debian:buster-slim
FROM debian:bookworm-slim
LABEL Maintainer="Denis Barbaron <denis.barbaron@orange.com>"
LABEL Name="STF"
@@ -10,7 +10,7 @@ LABEL Url="https://github.com/devicefarmer/stf/"
LABEL Description="STF docker image for x86_64 architecture"
# Sneak the stf executable into $PATH.
ENV PATH /app/bin:$PATH
ENV PATH=/app/bin:$PATH
# Work in app dir by default.
WORKDIR /app
@@ -22,11 +22,13 @@ COPY . /tmp/build/
RUN export DEBIAN_FRONTEND=noninteractive && \
echo '--- Updating repositories' && \
apt-get update && \
echo '--- Upgrading repositories' && \
apt-get -y dist-upgrade && \
echo '--- Building node' && \
apt-get -y install wget python3 build-essential && \
cd /tmp && \
wget --progress=dot:mega \
https://nodejs.org/dist/v17.9.0/node-v17.9.0-linux-x64.tar.xz && \
https://nodejs.org/dist/v22.11.0/node-v22.11.0-linux-x64.tar.xz && \
tar -xJf node-v*.tar.xz --strip-components 1 -C /usr/local && \
rm node-v*.tar.xz && \
useradd --system \
@@ -42,12 +44,12 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
cd /tmp/build && \
export PATH=$PWD/node_modules/.bin:$PATH && \
sed -i'' -e '/phantomjs/d' package.json && \
echo 'npm install --python="/usr/bin/python3" --no-optional --loglevel http' | su stf -s /bin/bash && \
echo 'npm install --python="/usr/bin/python3" --omit=optional --loglevel http' | su stf -s /bin/bash && \
echo '--- Assembling app' && \
echo 'npm pack' | su stf -s /bin/bash && \
tar xzf devicefarmer-stf-*.tgz --strip-components 1 -C /app && \
echo '/tmp/build/node_modules/.bin/bower cache clean' | su stf -s /bin/bash && \
echo 'npm prune --production' | su stf -s /bin/bash && \
echo 'npm prune --omit=dev' | su stf -s /bin/bash && \
mv node_modules /app && \
chown -R root:root /app && \
echo '--- Cleaning up' && \
@@ -56,12 +58,16 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get -y purge wget python3 build-essential && \
apt-get -y clean && \
apt-get -y autoremove && \
cd /home/stf && \
rm -rf .npm .cache .config .local && \
rm -rf /var/cache/apt/* /var/lib/apt/lists/* && \
cd /app && \
rm -rf doc .github .tx .semaphore *.md *.yaml LICENSE Dockerfile* \
.eslintrc .nvmrc .tool-versions res/.eslintrc && \
rm -rf /tmp/*
# Switch to the app user.
USER stf
# Show help by default.
CMD stf --help
CMD ["stf", "--help"]

View File

@@ -1,2 +1,2 @@
#!/usr/bin/env node
#!/usr/bin/env -S node --no-deprecation
require('../lib/cli/please')

View File

@@ -2,46 +2,46 @@
"name": "stf",
"version": "0.1.0",
"dependencies": {
"angular": "~1.5.0-rc.2",
"angular-cookies": "~1.5.0-rc.2",
"angular-route": "~1.5.0-rc.2",
"angular-sanitize": "~1.5.0-rc.2",
"angular-animate": "~1.5.0-rc.2",
"angular-touch": "~1.5.0-rc.2",
"angular": "~1.8.3",
"angular-cookies": "~1.8.3",
"angular-route": "~1.8.3",
"angular-sanitize": "~1.8.3",
"angular-animate": "~1.8.3",
"angular-touch": "~1.8.3",
"lodash": "~3.10.1",
"oboe": "~2.1.2",
"ng-table": "~1.0.0-beta.9",
"angular-gettext": "~2.2.0",
"oboe": "~2.1.5",
"ng-table": "~1.0.0",
"angular-gettext": "~2.4.2",
"angular-ui-ace": "~0.2.3",
"angular-dialog-service": "~5.2.11",
"ng-file-upload": "~2.0.5",
"angular-growl-v2": "JanStevens/angular-growl-2#~0.7.9",
"underscore.string": "~3.2.3",
"bootstrap": "~3.3.6",
"bootstrap": "~3.4.1",
"font-lato-2-subset": "~0.4.0",
"packery": "~1.4.3",
"draggabilly": "~1.2.4",
"angular-elastic": "~2.5.1",
"angular-hotkeys": "chieffancypants/angular-hotkeys#~1.6.0",
"angular-borderlayout": "git://github.com/filearts/angular-borderlayout.git#7c9716aebd9260763f798561ca49d6fbfd4a5c67",
"angular-ui-bootstrap": "~1.1.1",
"angular-ui-bootstrap": "~1.1.2",
"ng-context-menu": "swimlane/ng-context-menu#~1.0.1",
"components-font-awesome": "~4.5.0",
"epoch": "~0.8.4",
"ng-epoch": "~1.0.7",
"eventEmitter": "~4.3.0",
"angular-ladda": "~0.3.1",
"d3": "~3.5.14",
"d3": "~3.5.17",
"spin.js": "~2.3.2",
"angular-xeditable": "~0.1.9"
},
"private": true,
"devDependencies": {
"angular-mocks": "~1.5.0-rc.2"
"angular-mocks": "~1.8.3"
},
"resolutions": {
"angular": "~1.5.0-rc.2",
"d3": "~3.5.5",
"angular": "~1.8.3",
"d3": "~3.5.17",
"spin.js": "~2.3.2",
"eventEmitter": "~4.3.0",
"epoch": "~0.8.4"

View File

@@ -14,6 +14,7 @@ const uuid = require('uuid')
const apiutil = require('../util/apiutil')
const Promise = require('bluebird')
const _ = require('lodash')
const timeutil = require('../util/timeutil')
dbapi.DuplicateSecondaryIndexError = function DuplicateSecondaryIndexError() {
Error.call(this)
@@ -1174,6 +1175,7 @@ dbapi.saveDeviceInitialState = function(serial, device) {
, owner: null
, status: device.status
, statusChangedAt: r.now()
, statusTimeStamp: timeutil.now('nano')
, ready: false
, reverseForwards: []
, remoteConnect: false
@@ -1223,10 +1225,26 @@ dbapi.unsetDeviceConnectUrl = function(serial) {
}))
}
dbapi.saveDeviceStatus = function(serial, status) {
dbapi.saveDeviceStatus = function(serial, status, statusTimeStamp) {
return db.run(r.table('devices').get(serial).update({
status: status
, statusChangedAt: r.now()
status:
r.branch(
r.expr(statusTimeStamp).gt(r.row('statusTimeStamp'))
, status
, r.row('status')
)
, statusChangedAt:
r.branch(
r.expr(statusTimeStamp).gt(r.row('statusTimeStamp'))
, r.now()
, r.row('statusChangedAt')
)
, statusTimeStamp:
r.branch(
r.expr(statusTimeStamp).gt(r.row('statusTimeStamp'))
, statusTimeStamp
, r.row('statusTimeStamp')
)
}))
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright © 2019,2023 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var util = require('util')
@@ -7,7 +7,7 @@ var util = require('util')
var _ = require('lodash')
var Promise = require('bluebird')
var uuid = require('uuid')
var adbkit = require('@devicefarmer/adbkit')
var adb = require('../../../util/adbutil')()
var dbapi = require('../../../db/api')
var logger = require('../../../util/logger')
var datautil = require('../../../util/datautil')
@@ -434,7 +434,7 @@ function getUserAccessTokens(req, res) {
function addAdbPublicKey(req, res) {
var data = req.swagger.params.adb.value
adbkit.util.parsePublicKey(data.publickey)
adb.util.parsePublicKey(data.publickey)
.then(function(key) {
return dbapi.lookupUsersByAdbKey(key.fingerprint)
.then(function(cursor) {

View File

@@ -1,5 +1,5 @@
/**
* Copyright © 2019,2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var http = require('http')
@@ -136,6 +136,8 @@ module.exports = function(options) {
, keys: [options.secret]
}))
app.disable('x-powered-by')
lifecycle.observe(function() {
[push, sub, pushdev, subdev].forEach(function(sock) {
try {

View File

@@ -1,3 +1,7 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var http = require('http')
var url = require('url')
var fs = require('fs')
@@ -96,6 +100,8 @@ module.exports = function(options) {
next()
})
app.disable('x-powered-by')
app.get('/', function(req, res) {
res.render('index')
})

View File

@@ -1,5 +1,5 @@
/**
* Copyright © 2019 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var http = require('http')
@@ -56,6 +56,8 @@ module.exports = function(options) {
next()
})
app.disable('x-powered-by')
app.get('/', function(req, res) {
res.redirect('/auth/ldap/')
})

View File

@@ -82,6 +82,8 @@ module.exports = function(options) {
app.use(basicAuthMiddleware)
}
app.disable('x-powered-by')
app.get('/', function(req, res) {
res.redirect('/auth/mock/')
})

View File

@@ -1,3 +1,7 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var http = require('http')
var express = require('express')
@@ -48,6 +52,8 @@ module.exports = function(options) {
, session: false
}))
app.disable('x-powered-by')
function isEmailAllowed(email) {
if (email) {
if (options.domain) {

View File

@@ -1,3 +1,7 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var http = require('http')
var openid = require('openid')
@@ -27,6 +31,8 @@ module.exports = function(options) {
app.set('strict routing', true)
app.set('case sensitive routing', true)
app.disable('x-powered-by')
app.get('/', function(req, res) {
res.redirect('/auth/openid/')
})

View File

@@ -1,3 +1,7 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var fs = require('fs')
var http = require('http')
@@ -88,6 +92,8 @@ module.exports = function(options) {
, session: false
}))
app.disable('x-powered-by')
app.post(
'/auth/saml/callback'
, function(req, res) {

View File

@@ -1,10 +1,13 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var syrup = require('@devicefarmer/stf-syrup')
var Promise = require('bluebird')
var _ = require('lodash')
var logger = require('../../../util/logger')
const util = require('util')
const adbkit = require('@devicefarmer/adbkit')
module.exports = syrup.serial()
.dependency(require('../support/adb'))
@@ -38,7 +41,7 @@ module.exports = syrup.serial()
throw new Error(util.format('Cleanup %s is not allowed!', folder))
}
})
log.debug('Cleanup folders: %j', options.cleanupFolder)
log.info('Cleanup folders: %j', options.cleanupFolder)
function listPackages() {
return adb.getPackages(options.serial)
@@ -56,14 +59,14 @@ module.exports = syrup.serial()
return adb
// get file size
.shell(options.serial, util.format('du -h "%s"', filename))
.then(adbkit.util.readAll)
.then(adb.util.readAll)
.then(function(output) {
// output is in format: size filename. extract size;
var size = output.toString().split('\t')[0]
log.info('Removing %s (%s)', filename, size)
return adb
.shell(options.serial, util.format('rm -rf "%s"', filename))
.then(adbkit.util.readAll)
.then(adb.util.readAll)
})
.catch(function(err) {
log.warn(util.format('Unable to clean %s folder', filename), err)
@@ -149,7 +152,7 @@ module.exports = syrup.serial()
, plugin.disableBluetooth
, plugin.cleanFolders
, function() {
log.debug('Cleanup done')
log.info('Cleanup done')
}
], function(fn) {
return fn()

View File

@@ -1,7 +1,10 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var util = require('util')
var syrup = require('@devicefarmer/stf-syrup')
var adbkit = require('@devicefarmer/adbkit')
var logger = require('../../../../util/logger')
var wire = require('../../../../wire')
@@ -35,7 +38,7 @@ module.exports = syrup.serial()
var file = util.format('/data/local/tmp/minicap_%d.jpg', Date.now())
return minicap.run('minicap-apk', util.format(
'-P %s -s >%s', projectionFormat(), file))
.then(adbkit.util.readAll)
.then(adb.util.readAll)
.then(function() {
return adb.stat(options.serial, file)
})
@@ -55,7 +58,7 @@ module.exports = syrup.serial()
})
.finally(function() {
return adb.shell(options.serial, ['rm', '-f', file])
.then(adbkit.util.readAll)
.then(adb.util.readAll)
})
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
* Copyright © 2022-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var util = require('util')
@@ -10,7 +10,6 @@ var WebSocket = require('ws')
var uuid = require('uuid')
var EventEmitter = require('eventemitter3')
var split = require('split')
var adbkit = require('@devicefarmer/adbkit')
var logger = require('../../../../util/logger')
var lifecycle = require('../../../../util/lifecycle')
@@ -386,7 +385,7 @@ module.exports = syrup.serial()
return Promise.all([
output.waitForEnd()
, adb.shell(options.serial, ['kill', signum, pid])
.then(adbkit.util.readAll)
.then(adb.util.readAll)
.return(true)
])
.timeout(2000)

View File

@@ -1,11 +1,13 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var util = require('util')
var Promise = require('bluebird')
var syrup = require('@devicefarmer/stf-syrup')
var split = require('split')
var EventEmitter = require('eventemitter3')
var adbkit = require('@devicefarmer/adbkit')
var Parser = require('@devicefarmer/adbkit/lib/adb/parser')
var wire = require('../../../../wire')
var logger = require('../../../../util/logger')
@@ -351,7 +353,7 @@ module.exports = syrup.serial()
return Promise.all([
output.waitForEnd()
, adb.shell(options.serial, ['kill', signum, pid])
.then(adbkit.util.readAll)
.then(adb.util.readAll)
.return(true)
])
.timeout(2000)
@@ -379,7 +381,7 @@ module.exports = syrup.serial()
TouchConsumer.prototype._readBanner = function(socket) {
log.info('Reading minitouch banner')
var parser = new Parser(socket)
var parser = new adb.Parser(socket)
var banner = {
pid: -1 // @todo
, version: 0

View File

@@ -1,3 +1,7 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var util = require('util')
var syrup = require('@devicefarmer/stf-syrup')
@@ -9,7 +13,6 @@ var pathutil = require('../../../util/pathutil')
var streamutil = require('../../../util/streamutil')
var promiseutil = require('../../../util/promiseutil')
var logger = require('../../../util/logger')
const adbkit = require('@devicefarmer/adbkit')
module.exports = syrup.serial()
.dependency(require('../support/adb'))
@@ -101,16 +104,16 @@ module.exports = syrup.serial()
function grantPermission(permission, minSdk) {
if (minSdk && sdk.level < minSdk) {
log.debug('SDK version (%d) is lower than %d, permission %s not supported',
log.warn('SDK version (%d) is lower than %d, permission %s not supported',
sdk.level, minSdk, permission)
return Promise.resolve()
}
log.debug('Granting permission to STFService: ' + permission)
log.info('Granting permission to STFService: ' + permission)
return adb.shell(options.serial, [
'pm', 'grant', resource.pkg, permission])
.then(adbkit.util.readAll)
.then(adb.util.readAll)
.then(function() {
log.debug('Permission granted %s', permission)
log.info('Permission granted %s', permission)
})
.catch(function(err) {
log.error('Failed to grant permission %s: %s', permission, err)

View File

@@ -1,18 +1,15 @@
/**
* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var syrup = require('@devicefarmer/stf-syrup')
var adbkit = require('@devicefarmer/adbkit')
var logger = require('../../../util/logger')
var promiseutil = require('../../../util/promiseutil')
module.exports = syrup.serial()
.define(function(options) {
var log = logger.createLogger('device:support:adb')
var adb = adbkit.createClient({
host: options.adbHost
, port: options.adbPort
})
adb.Keycode = adbkit.Keycode
var adb = require('../../../util/adbutil')(options)
function ensureBootComplete() {
return promiseutil.periodicNotify(

View File

@@ -1,3 +1,7 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var http = require('http')
var express = require('express')
@@ -19,6 +23,8 @@ module.exports = function(options) {
app.set('case sensitive routing', true)
app.set('trust proxy', true)
app.disable('x-powered-by')
;['/static/auth/*', '/auth/*'].forEach(function(route) {
app.all(route, function(req, res) {
proxy.web(req, res, {

View File

@@ -1,5 +1,5 @@
/**
* Copyright © 2019 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var Promise = require('bluebird')
@@ -135,8 +135,12 @@ module.exports = db.ensureConnectivity(function(options) {
appDealer.send([channel, data])
})
.on(wire.DeviceStatusMessage, function(channel, message, data) {
dbapi.saveDeviceStatus(message.serial, message.status)
appDealer.send([channel, data])
dbapi.saveDeviceStatus(message.serial, message.status, message.statusTimeStamp)
.then(function(stats) {
if (stats.replaced) {
appDealer.send([channel, data])
}
})
})
.on(wire.DeviceHeartbeatMessage, function(channel, message, data) {
appDealer.send([channel, data])

View File

@@ -1,4 +1,7 @@
var adb = require('@devicefarmer/adbkit')
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var Promise = require('bluebird')
var _ = require('lodash')
var EventEmitter = require('eventemitter3')
@@ -12,12 +15,11 @@ var lifecycle = require('../../util/lifecycle')
var srv = require('../../util/srv')
var zmqutil = require('../../util/zmqutil')
const timeutil = require('../../util/timeutil')
module.exports = function(options) {
var log = logger.createLogger('provider')
var client = adb.createClient({
host: options.adbHost
, port: options.adbPort
})
var client = require('../../util/adbutil')(options)
var workers = {}
var solo = wireutil.makePrivateChannel()
var lists = {
@@ -370,6 +372,7 @@ module.exports = function(options) {
, wireutil.envelope(new wire.DeviceStatusMessage(
device.id
, wireutil.toDeviceStatus(device.type)
, timeutil.now('nano')
))
])

View File

@@ -1,3 +1,7 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var http = require('http')
var url = require('url')
var util = require('util')
@@ -18,6 +22,8 @@ module.exports = function(options) {
app.set('case sensitive routing', true)
app.set('trust proxy', true)
app.disable('x-powered-by')
app.get('/s/apk/:id/:name/manifest', function(req, res) {
var orig = util.format(
'/s/blob/%s/%s'

View File

@@ -1,3 +1,7 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var http = require('http')
var util = require('util')
@@ -20,6 +24,8 @@ module.exports = function(options) {
app.set('case sensitive routing', true)
app.set('trust proxy', true)
app.disable('x-powered-by')
app.get(
'/s/image/:id/:name'
, requtil.limit(options.concurrency, function(req, res) {

View File

@@ -1,3 +1,7 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var http = require('http')
var util = require('util')
var path = require('path')
@@ -32,6 +36,8 @@ module.exports = function(options) {
app.use(bodyParser.json())
app.use(validator())
app.disable('x-powered-by')
function putObject(plugin, file) {
return new Promise(function(resolve, reject) {
var id = uuid.v4()

View File

@@ -1,3 +1,7 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var http = require('http')
var util = require('util')
var path = require('path')
@@ -28,6 +32,8 @@ module.exports = function(options) {
app.use(bodyParser.json())
app.use(validator())
app.disable('x-powered-by')
storage.on('timeout', function(id) {
log.info('Cleaning up inactive resource "%s"', id)
})

View File

@@ -1,3 +1,7 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var logger = require('../../util/logger')
var lifecycle = require('../../util/lifecycle')
var zmqutil = require('../../util/zmqutil')
@@ -17,18 +21,18 @@ module.exports = function(options) {
// App/device output
var pub = zmqutil.socket('pub')
pub.bindSync(options.endpoints.pub)
pub.bind(options.endpoints.pub)
log.info('PUB socket bound on', options.endpoints.pub)
// Coordinator input/output
var dealer = zmqutil.socket('dealer')
dealer.bindSync(options.endpoints.dealer)
dealer.bind(options.endpoints.dealer)
dealer.on('message', proxy(pub))
log.info('DEALER socket bound on', options.endpoints.dealer)
// App/device input
var pull = zmqutil.socket('pull')
pull.bindSync(options.endpoints.pull)
pull.bind(options.endpoints.pull)
pull.on('message', proxy(dealer))
log.info('PULL socket bound on', options.endpoints.pull)

View File

@@ -10,7 +10,7 @@ var socketio = require('socket.io')
var Promise = require('bluebird')
var _ = require('lodash')
var request = Promise.promisifyAll(require('request'))
var adbkit = require('@devicefarmer/adbkit')
var adb = require('../../util/adbutil')()
var uuid = require('uuid')
var logger = require('../../util/logger')
@@ -464,7 +464,7 @@ module.exports = function(options) {
})
})
.on('user.keys.adb.add', function(data) {
return adbkit.util.parsePublicKey(data.key)
return adb.util.parsePublicKey(data.key)
.then(function(key) {
return dbapi.lookupUsersByAdbKey(key.fingerprint)
.then(function(cursor) {

91
lib/util/adbutil.js Normal file
View File

@@ -0,0 +1,91 @@
/**
* Copyright © 2024 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var adbkit = require('@devicefarmer/adbkit')
module.exports = function(options) {
var adb = null
if (adbkit.hasOwnProperty('Adb')) {
// adbkit 3.x version
adb = {
client: typeof options === 'undefined' ?
adbkit.Adb.createClient() :
adbkit.Adb.createClient({
host: options.adbHost
, port: options.adbPort
})
, Keycode: adbkit.KeyCodes
, Parser: adbkit.Parser
, util: adbkit.Adb.util
, readdir: function(serial, path) {
return this.client.getDevice(serial).readdir(path)
}
, stat: function(serial, path) {
return this.client.getDevice(serial).stat(path)
}
, openLocal: function(serial, path) {
return this.client.getDevice(serial).openLocal(path)
}
, openLogcat: function(serial, options) {
return this.client.getDevice(serial).openLogcat(options)
}
, shell: function(serial, command) {
return this.client.getDevice(serial).shell(command)
}
, push: function(serial, contents, path, mode) {
return this.client.getDevice(serial).push(contents, path, mode)
}
, pull: function(serial, path) {
return this.client.getDevice(serial).pull(path)
}
, install: function(serial, apk) {
return this.client.getDevice(serial).install(apk)
}
, installRemote: function(serial, apk) {
return this.client.getDevice(serial).installRemote(apk)
}
, uninstall: function(serial, pkg) {
return this.client.getDevice(serial).uninstall(pkg)
}
, clear: function(serial, pkg) {
return this.client.getDevice(serial).clear(pkg)
}
, reboot: function(serial) {
return this.client.getDevice(serial).reboot()
}
, waitBootComplete: function(serial) {
return this.client.getDevice(serial).waitBootComplete()
}
, getPackages: function(serial) {
return this.client.getDevice(serial).getPackages()
}
, getProperties: function(serial) {
return this.client.getDevice(serial).getProperties()
}
, startActivity: function(serial, options) {
return this.client.getDevice(serial).startActivity(options)
}
, createTcpUsbBridge: function(serial, options) {
return this.client.createTcpUsbBridge(serial, options)
}
, trackDevices: function() {
return this.client.trackDevices()
}
}
}
else {
// adbkit 2.x version
adb = typeof options === 'undefined' ?
adbkit.createClient() :
adbkit.createClient({
host: options.adbHost
, port: options.adbPort
})
adb.Keycode = adbkit.Keycode
adb.Parser = require('@devicefarmer/adbkit/lib/adb/parser')
adb.util = adbkit.util
}
return adb
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright © 2019 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
* Copyright © 2019-2014 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
const Promise = require('bluebird')
@@ -184,7 +184,7 @@ apiutil.setIntervalWrapper = function(fn, numTimes, delay) {
return fn().then(function(result) {
if (result.status || ++counter === numTimes) {
if (!result.status && counter === numTimes) {
log.debug('%s() failed %s times in a loop!', fn.name, counter)
log.warn('%s() failed %s times in a loop!', fn.name, counter)
}
clearInterval(interval)
resolve(result.data)

View File

@@ -1,6 +1,10 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var util = require('util')
var adb = require('@devicefarmer/adbkit')
var adb = require('./adbutil')()
var Promise = require('bluebird')
var keyutil = module.exports = Object.create(null)

View File

@@ -1,5 +1,5 @@
//
// Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
// Copyright © 2022-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
//
// ISSUE-100 (https://github.com/openstf/stf/issues/100)
@@ -8,7 +8,7 @@
// Setting TCP_KEEPALIVE option true, to all the zmq sockets
// won't let it die
var zmq = require('zeromq')
var zmq = require('zeromq/v5-compat')
var log = require('./logger').createLogger('util:zmqutil')

View File

@@ -1,7 +1,14 @@
//
// Copyright © 2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
// Copyright © 2022-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
//
/* global BigInt */
/* eslint no-extend-native: ["error", { "exceptions": ["BigInt"] }] */
BigInt.prototype.toJSON = function() {
return Number(this)
}
var uuid = require('uuid')
var wire = require('./')

View File

@@ -373,6 +373,7 @@ enum DeviceStatus {
message DeviceStatusMessage {
required string serial = 1;
required DeviceStatus status = 2;
required double statusTimeStamp = 3;
}
message DeviceDisplayMessage {

View File

@@ -1,6 +1,6 @@
{
"name": "@devicefarmer/stf",
"version": "3.7.1",
"version": "3.7.2",
"description": "Smartphone Test Farm",
"keywords": [
"adb",
@@ -34,7 +34,7 @@
"local": "node lib/cli/index.js local"
},
"dependencies": {
"@devicefarmer/adbkit": "^2.11.3",
"@devicefarmer/adbkit": "^3.3.7",
"@devicefarmer/adbkit-apkreader": "^3.2.4",
"@devicefarmer/adbkit-monkey": "^1.2.1",
"@devicefarmer/minicap-prebuilt": "^2.7.2",
@@ -59,13 +59,13 @@
"csurf": "^1.7.0",
"debug": "^3.1.0",
"eventemitter3": "^1.2.0",
"express": "^4.14.0",
"express-validator": "^2.20.8",
"express": "^4.18.0",
"express-validator": "^4.3.0",
"file-saver": "1.3.3",
"formidable": "^1.2.0",
"gm": "^1.23.0",
"hipchatter": "^0.3.1",
"http-proxy": "^1.11.2",
"http-proxy": "^1.18.1",
"in-publish": "^2.0.0",
"jws": "^3.1.0",
"ldapjs": "^1.0.0",
@@ -80,7 +80,7 @@
"passport-saml": "^0.15.0",
"protobufjs": "^3.8.2",
"proxy-addr": "^2.0.7",
"pug": "^2.0.0-beta4",
"pug": "^3.0.3",
"request": "^2.67.0",
"request-progress": "^2.0.1",
"rethinkdb": "^2.0.2",
@@ -100,7 +100,7 @@
"ws": "^3.0.0",
"yargs": "^6.6.0",
"yauzl": "^2.10.0",
"zeromq": "^5.0.0"
"zeromq": "^6.1.2"
},
"devDependencies": {
"async": "^2.0.1",
@@ -145,9 +145,9 @@
"protractor": "^5.4.1",
"protractor-html-reporter-2": "1.0.4",
"raw-loader": "^0.5.1",
"sass": "^1.49.9",
"sass": "^1.80.6",
"sass-loader": "^7.3.1",
"script-loader": "^0.7.0",
"script-loader": "^0.7.2",
"sinon": "^1.17.2",
"sinon-chai": "^2.7.0",
"socket.io-client": "1.4.8",
@@ -159,7 +159,7 @@
"webpack-dev-server": "^2.11.5"
},
"engines": {
"node": ">= 6.9"
"node": ">= 18"
},
"externalDependencies": {
"rethinkdb": ">= 2.2",

View File

@@ -1,5 +1,5 @@
/**
* Copyright © 2019,2022 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
var oboe = require('oboe')
@@ -136,6 +136,10 @@ module.exports = function DeviceServiceFactory($http, socket, EnhanceDeviceServi
function changeListener(event) {
var device = get(event.data)
if (device) {
if (event.data.likelyLeaveReason === 'status_change' &&
device.statusTimeStamp > event.data.statusTimeStamp) {
return
}
modify(device, event.data)
if (!options.filter(device)) {
remove(device)

View File

@@ -1,3 +1,7 @@
//
Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
//
.widget-container.fluid-height(ng-controller='ExplorerCtrl').stf-explorer
.heading
@@ -42,6 +46,6 @@
span(ng-show='f.mode|fileIsDir') -
span(ng-hide='f.mode|fileIsDir') {{f.size|formatFileSize}}
td
span {{f.mtime|formatFileDate}}
span {{f.mtimeMs|formatFileDate}}
td
i {{f.mode|formatPermissionMode}}

View File

@@ -16,6 +16,9 @@ module.exports = function MenuCtrl(
, $cookies
, $window) {
$window.angular.version = {}
$window.d3.version = {}
SettingsService.bind($scope, {
target: 'lastUsedDevice'
})

View File

@@ -1,3 +1,7 @@
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
module.exports = function AccessTokensCtrl($scope, AccessTokenService) {
$scope.accessTokenTitles = []
@@ -5,8 +9,8 @@ module.exports = function AccessTokensCtrl($scope, AccessTokenService) {
function updateTokens() {
AccessTokenService.getAccessTokens()
.success(function(response) {
$scope.accessTokenTitles = response.titles || []
.then(function(response) {
$scope.accessTokenTitles = response.data.titles || []
})
}

View File

@@ -1,8 +1,10 @@
/**
* Copyright © 2019 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
module.exports = function SignInCtrl($scope, $http, CommonService) {
module.exports = function SignInCtrl($window, $scope, $http, CommonService) {
$window.angular.version = {}
$scope.error = null
@@ -13,12 +15,12 @@ module.exports = function SignInCtrl($scope, $http, CommonService) {
}
$scope.invalid = false
$http.post('/auth/api/v1/ldap', data)
.success(function(response) {
.then(function(response) {
$scope.error = null
location.replace(response.redirect)
location.replace(response.data.redirect)
})
.error(function(response) {
switch (response.error) {
.catch(function(response) {
switch (response.data.error) {
case 'ValidationError':
$scope.error = {
$invalid: true

View File

@@ -1,8 +1,10 @@
/**
* Copyright © 2019 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
module.exports = function SignInCtrl($scope, $http, CommonService) {
module.exports = function SignInCtrl($window, $scope, $http, CommonService) {
$window.angular.version = {}
$scope.error = null
@@ -13,12 +15,12 @@ module.exports = function SignInCtrl($scope, $http, CommonService) {
}
$scope.invalid = false
$http.post('/auth/api/v1/mock', data)
.success(function(response) {
.then(function(response) {
$scope.error = null
location.replace(response.redirect)
location.replace(response.data.redirect)
})
.error(function(response) {
switch (response.error) {
.catch(function(response) {
switch (response.data.error) {
case 'ValidationError':
$scope.error = {
$invalid: true

3084
yarn.lock

File diff suppressed because it is too large Load Diff