:H",
            "version": "3.1"
        }
    },
    "problemtype": {
        "problemtype_data": [
            {
                "description": [
                    {
                        "lang": "eng",
                        "value": "CWE-275 Permission Issues"
                    }
                ]
            }
        ]
    },
    "references": {
        "reference_data": [
            {
                "name": "https://csirt.divd.nl/cases/DIVD-2021-00037",
                "refsource": "CONFIRM",
                "url": "https://csirt.divd.nl/cases/DIVD-2021-00037"
            },
            {
                "name": "https://csirt.divd.nl/CVE-2022-25153",
                "refsource": "CONFIRM",
                "url": "https://csirt.divd.nl/CVE-2022-25153"
            }
        ]
    },
    "source": {
        "advisory": "DIVD-2021-00037",
        "discovery": "INTERNAL"
    }
}
---
The general conditions of consignment of the One Soul Many Stories company govern the relations between the client, hereinafter referred to as “the depositor” and the company One Soul Many Stories (OSMS). The General Conditions of consignment have a contractual value. The company OSMS allows the depositor to consign one or more items, which will then be put on sale in the next pop up event.
The consignment of an article is free and open. The depositor must have legally come into possession of the articles he is depositing and these must comply with the law and regulations in force on the day of the consignment. The depositor is responsible for the quality of the articles deposited and must be able to prove/certify its authenticity (Luxury goods) if requested by OSMS or the buyer (certificate of authenticity, purchase invoice…). In the event of a hidden defect or missing/modified part of the item, he must reimburse or at least compensate OSMS, or the buyer directly.
- Not accept the articles presented, in particular if the articles do not meet its quality, safety or price requirements.
- To cancel the contract and withdraw without notice from the sale, by informing the depositor as soon as possible, any article for which the company OSMS has doubts about the origin or the identification of the presumed owner or any article presenting a defect not indicated during the consignment and which will make it unfit for sale under the quality conditions required by the company OSMS. In the event of non-conformity of the product, the depositor has 7 working days to recover it. After this period, it will automatically be given over to charity.
A consignment sheet is given to the depositor depositing one or more articles.
A processing time of 7 working days may be applied before the contract is sent to the depositor.
- The amount that will be paid to the depositor following the sale of the item.
- Approval for the participation to the sales operation (20% off selling price for unsold items) on the last day of the pop up, from 2pm.
OSMS reserves the right to freely set the price of the item taken into consignment. This price, if accepted by the depositor, is entered on the consignment contract. This price corresponds to the amount that will be paid to the Depositor following the sale of the item and includes OSMS' commission as follow: 30% commission applied on items selling for more than $150 and 35% commission for items selling for $150 or less.
The depositor has the right to refuse or renegotiate the price fixed by OSMS.
Payment is made at the end of the consignment (pop up sale). Payment can be made either by Bank Transfer or Paynow, as specified by the depositor on the consignment contract.
All unsold items not collected within the deadlines mentioned in the consignment contract will be donated to charities. The depositor must imperatively recover his unsold articles within 7 working days (from Monday to Sunday - Day & Time will have to be pre-agreed with OSMS by Whatsapp or Email). It is recalled that the date on which the items are donated to charities appears on the depositor's contract.
The Depositor has the option of sending a third party to collect his unsold items if previously confirmed and approved with OSMS team.
If an item does not appear to be sold but it is not found by OSMS after the pop up sale, a search procedure is set up. This procedure can last up to one calendar month. At the end of this search procedure, the article will be returned to the depositor if it has been found or paid to him at the price appearing in the consignment contract if it has not been found.
OSMS reserves the right to adapt or modify these general conditions of consignment at any time.import pytest
import sys
import os
import datetime
import shutil
import sqlite3
import importlib
import re

from typing import Optional, List

import gwaripper.migrate as migrate

from utils import load_db_from_sql_file, TESTS_DIR, setup_tmpdir, load_db
from gwaripper.db import export_to_sql, load_or_create_sql_db


def test_export_to_sql(setup_tmpdir):
    tmpdir = setup_tmpdir

    sql_file = os.path.join(TESTS_DIR, "db_schemas_test_files", "gwarip_db.sqlite.sql")
    db_expected = load_db_from_sql_file(sql_file, ":memory:", True)
    db_expected.row_factory = None

    # same tables, indices and sql stmt
    c_exp = db_expected.execute(
            "SELECT type, name, tbl_name, sql FROM sqlite_master ORDER BY name")
    expected = c_exp.fetchall()

    exported_sql = os.path.join(tmpdir, 'exported.sql')
    export_to_sql(exported_sql, db_expected)
    # export_to_sql uses sqlite3.Row check that it was reset
    assert db_expected.row_factory is None

    db_actual = load_db_from_sql_file(exported_sql, ":memory:", True)
    db_actual.row_factory = None

    # same tables, indices and sql stmt
    c_act = db_actual.execute(
            "SELECT type, name, tbl_name, sql FROM sqlite_master ORDER BY name")
    actual = c_act.fetchall()
    assert expected == actual

    # technically already the same since we compare sql statements
    # same table setups: columns, types, nullable etc.
    for exp_row, act_row in zip(expected, actual):
        # Unfortunately pragma statements do not work with parameters
        exp_tbl = c_exp.execute(
                f"pragma table_info('{exp_row[2]}')").fetchall()
        act_tbl = c_act.execute(
                f"pragma table_info('{act_row[2]}')").fetchall()
        assert exp_tbl == act_tbl

    # compare all rows of all tables
    for sql_master_row in expected:
        if sql_master_row[0]!= 'table':
            continue
        tbl_name = sql_master_row[2]

        expected = c_exp.execute(f"SELECT * FROM {tbl_name}").fetchall()
        actual = c_act.execute(f"SELECT * FROM {tbl_name}").fetchall()
        assert expected == actual


def test_db_migration(setup_tmpdir, monkeypatch, caplog):
    tmpdir = setup_tmpdir
    test_files = os.path.join(TESTS_DIR, 'db_schemas_test_files')

    migrations_dirname ='migrations'
    tmp_migrations = os.path.join(tmpdir, migrations_dirname)
    # so importlib finds our 'package'
    sys.path.insert(0, tmpdir)
    monkeypatch.setattr("gwaripper.migrate.MODULE_DIR", tmpdir)
    monkeypatch.setattr("gwaripper.migrate.MIGRATIONS_PATH", tmp_migrations)
    monkeypatch.setattr("gwaripper.migrate.LATEST_VERSION", -1)

    tmp_db_fn = os.path.join(tmpdir, 'test.sqlite')
    db = load_db_from_sql_file(os.path.join(test_files, 'gwarip_db.sqlite.sql'),
                               tmp_db_fn)
    db.close()

    m = migrate.Database(tmp_db_fn)
    assert m.is_versionized is False
